Hi, I'm trying to write a script that allows me to insert a file into MySql. I would like it to work under the user's session. I am getting error:(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 'WHERE user_id = 'dck172'(name, content)VALUES('dave.jpg','����\0JFIF\0\0d\0d' at line 1)
Here is the code I am having a problem with:

$colname_Recordset1 = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_Recordset1 = $_SESSION['MM_Username'];
}

//include('includes/create_thumb3.inc.php');
	if (!$insert = mysql_query("INSERT INTO mystuff.page WHERE user_id = '$colname_Recordset1'(name, content)VALUES('$content_name','$content')"))
echo (mysql_error());

Any help would be awesome, Thanks

You can't have a where clause in an Insert statement. See the format here.

Thanks, I didn't know that, still learning.

Try this query

$insert = mysql_query("INSERT INTO mystuff.pageser (name,content) VALUES('$content_name','$content') where user_id = '$colname_Recordset1'"));
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.