Mysql INSERT INTO working half way.

francoboy776

New Member
Messages
17
Reaction score
0
Points
1
Hi everyone
this script http://pastebin.com/9LwMEPHi

Uses hyridatuh (a class to connect to social media such as facebook google and twitter) and get their user data such as name, email, gender.

My problem is that the script if working very well when data comes from facebook or Twitter.
It does check if datas exist in database if so echo it exists, if not insert datas in the database.

Problem is when provider of data is Google, the script seems to insert the data and echoing the inserted data confirmation, but it is not. No data from google are inserted in database.

Do you guys see any mistakes in the code :)confused:)

PS : basic script can be tested here
http://www.entendu.info/social/

If you have any question, comment or suggestion to render my code better, feel free
 

essellar

Community Advocate
Community Support
Messages
3,295
Reaction score
227
Points
63
I don't see anything wrong with the code, but the data may be a problem. One of the "problems" with PHP (a characteristic it shares with JavaScript) is that it does automatic type coercion, so treating data as a string will usually cause it to act an awful lot like a string. That means that echo can be useful, but it's not a foolproof diagnostic since if there's an easy way to make it look like a string, PHP will make it look like a string. MySQL isn't nearly so co-operative; it will try to use the data type it's given, and PHP might be interpreting what Google sends you as a hash/array or some such nonsense. You'd need to find out what the data is when it's sent to the PDO execute statement (or force a conversion to string by concatenating with "", which should work, given that echo has no trouble with it).
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
1. You don't test the result of the execute() command. You should.
2. Try using errorInfo() and then printing out the results.
3. Print out what
Code:
array('email' => $email, 'username' => $username, 
'password' => $password, 'firstname' => $first_name, 'lastname' => $last_name,
 'gender' => $gender, 'identifier' => $identifier, 'provider' => $provider_name)
actually is trying to put into the database when the info is coming from Google.
 
Top