Jump to content

PHP MySQL error


punky79

Recommended Posts

Error in INSERT: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

 

Any ideas of what this error might be.

Here is my SQL code in a PHP script.

 

$v=UPLOAD_DIR.$_SESSION['MM_Username'].'/'.$now.$_SESSION['MM_Username'].'-'.$file;

		//copy image to database

		$sql ="SELECT user_id FROM user WHERE username = '".$_SESSION['MM_Username']."'";
		$queryresult = mysql_query($sql)
   			or die (mysql_error());
		if (mysql_num_rows($queryresult) > 0) {
    		$row=mysql_fetch_assoc($queryresult);
    		$userid=$row['user_id'];
		}

		$resins=mysql_query("INSERT INTO gallery (user_id, image_name) VALUES ($userid,'$v'")
		or die("Error in INSERT: ".mysql_error());

 

Link to comment
https://forums.phpfreaks.com/topic/94322-php-mysql-error/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.