Files not inserting to Mysql

Hi,

Got a problem with some lines of a code where after a file upload it should insert data into the connected database for the files to show up on the mainpage but it doesn’t. The file upload just fine into FTP tho.

The code itself is the following:

$query = “INSERT INTO videos SET USERID=‘$_SESSION[USERID]’, title='”.mysql_real_escape_string($thetitle).“‘, description=’”.mysql_real_escape_string($thedesc).“‘, tags=’”.mysql_real_escape_string($thetags).“‘, categories=’”.mysql_real_escape_string($thecat).“‘, filesize=’$space’, public='”.mysql_real_escape_string($thepublic).“‘, time_added=’”.time().“‘, date_added=’”.date(“Y-m-d”).“‘, $active, allowcomments=’”.mysql_real_escape_string($theallowcomments).“‘, allowratings=’”.mysql_real_escape_string($theallowratings).“‘, allowembeds=’”.mysql_real_escape_string($theallowembeds).“‘, allowdownloads=’”.mysql_real_escape_string($theallowdownloads).“‘$addseriesdata, mature=’”.mysql_real_escape_string($themature).“'”;

				$conn->execute($query);
				$videoid = mysql_insert_id();
    			
				$original = $videoid.".".$ph;
				$videor = $config['originalvdir'].'/'.$original;

Can anyone see anything off here?

First glaring issue is that you are using the incorrect SQL statement for INSERT.

Insert query uses:

INSERT INTO table VALUES(x,y,z)

or

INSERT INTO table(col x, col y, col z) VALUES(x,y,z)

Update query uses:

UPDATE table SET col x = x, col y = y, col z = z WHERE column =  condition

Second, if you are using PDO, you can do without mysql_insert_id() and user lastInsertId()


$conn->execute($query);
$videoid = $conn->lastInsertId();

http://www.php.net/manual/en/pdo.lastinsertid.php