Why doesn’t this simple insertion work? The only value not inserted is $streamName, if I remove that value from code then everything works, here’s the code:
$userId= $_SESSION['kt_login_id'];
$streamName= $_GET['streamName'];
$streamDuration= $_GET['streamDuration'];
$recorderId= $_GET['recorderId'];
$con = mysql_connect("localhost","wwwmeety_staff","xxxxxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("wwwmeety_ourstaff", $con);
mysql_query("INSERT INTO recordedvideos (user_id, streamName, record_duration, recorder_id)
VALUES ($userId, $streamName, $streamDuration, $recorderId)");
mysql_close($con);
and MySQL export
CREATE TABLE IF NOT EXISTS `recordedvideos` (
`record_id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) DEFAULT NULL,
`streamName` text,
`record_duration` text,
`recorder_id` text,
PRIMARY KEY (`record_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
You forgot enclose string in quotes.
But to avoid sql injection is preferable this approach: http://php.net/manual/en/function.mysql-query.php