These all echo correctly but the query doesn't insert anything? it use to work and just broke.
echo $social_id;
echo $name;
echo $email;
echo $social_network;
echo $profile_pic;
mysql_query("INSERT INTO users (social_id, name, email, social_network, profile_pic)
VALUES ('$social_id', '$name','$email', '$social_network','$profile_pic')");
$user_id = mysql_insert_id();
Try removing the exit()
call:
echo $social_id;
echo $name;
echo $email;
echo $social_network;
echo $profile_pic;
exit();
mysql_query("INSERT INTO users (social_id, name, email, social_network, profile_pic)
VALUES ('$social_id', '$name','$email', '$social_network','$profile_pic')");
$user_id = mysql_insert_id();
I'm no PHP expert, but is it because you have an exit()
call before the insert statement runs, and therefore the query is never reached?
You are calling exit()
directly before your query, so the query is never executed.
Use mysql_errno() and mysql_error() to view any errors that may be reported when PHP attempts to select or query the database like:
<?php
$social_id = "test";
$name = "Bob";
$email = "myself@localhost";
$social_network = "facespace";
$profile_pic = "me.png";
$conn = mysql_connect("localhost", "roots", "for_the_cubs");
if(!$conn){
die('Could not connect to the database');
}
mysql_select_db("mydb", $conn);
echo mysql_errno($conn) . " : " . mysql_error($conn);
mysql_query("INSERT INTO users
(social_id, name, email, social_network, profile_pic)
VALUES
('$social_id', '$name','$email', '$social_network','$profile_pic')");
echo mysql_errno($conn) . " : " . mysql_error($conn);
?>
Double-check to ensure the mysql extension is enabled in php.ini.
It may be possible that something was upgraded on the server and the mysql extension was not re-added, opting for PDO or mysqli instead