...

View Full Version : MySQL query problem again...



iceflyin
08-20-2007, 06:17 PM
$eventName is the table name, and the variable is correct. Checked that... Whats wrong with my INSERT syntax??? I have looked it over again and again...




$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die("Connection Failure");
mysql_select_db($dbname,$conn) or die("Select Failure");
$eventName = "event" . $eid;
mysql_query ("INSERT INTO '$eventName' ('eid', 'photo'),
VALUES ('$eid', '$uniqueName')", $conn) or die ("Insert failed");

ess
08-20-2007, 06:21 PM
you need to write the "VALUES" keyword in your SQL Statement

mysql_query ("INSERT INTO '$eventName' VALUES ('eid', 'photo'),

Fumigator
08-20-2007, 07:15 PM
I see you have the keyword "VALUES", but you have an extra comma in there that can't be there right before the "VALUES" keyword.

Also you are enclosing all your table and column names in quotes-- that is incorrect. If you need to, you can use backticks (`) which are different than single quotes (') and are only required if you have badly named tables and columns (i.e. you are using MySQL reserved words such as group, order, select, having, etc).

I also question your database design that uses an ID in the name of a table, rather than using one table with a primary key column.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum