facebook connect user info to mysql database [closed]-Collection of common programming errors

It’s probably because you have some weird syntax (at least I have never seen it) in this line:

$result = mysql_query("INSERT INTO 'feelmyli_facebooktry'.'users' ('name', 'email', 'password', 'gender', 'dob', 'phone') VALUES ('$name', '$email', '$password', '$gender', '$dob', '$phone')");

You have already selected the db in the previous line (mysql_select_db). So no need to repeat that in the query.

Query should only mention the TABLE name. And the single quotes don’t belong around the tablename or the column names.

Like this:

$result = mysql_query("INSERT INTO users (name, email, password, gender, dob, phone) VALUES ('$name', '$email', '$password', '$gender', '$dob', '$phone')");

I should also note that mysql_ functions are deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used. Check out this link to decide on which extension suits you best.

Generally speaking you should also escape input, but since Facebook supplies this it could be considered reliable. Still would be better to escape it. Better safe than sorry.

Originally posted 2013-11-10 00:08:36.