I run this function and the value of the post form doesn’t insert into the DB. I’m not getting any error messages but I checked and saw that $this->user_id is populating. Am I missing something else?
function senddata () {
$con = mysql_connect("localhost","root","XXXXX");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("user", $con);
$sql="INSERT INTO profile (collegemajor) VALUE('$_POST[major]') WHERE userid=$this->user_id";
mysql_close($con);
}
First of all, I don’t see the mysql_query() – the function to execute the query.
It seems like the problem is here:
Use
$sql="INSERT INTO profile (collegemajor) VALUE('$_POST[major]');instead.The code: