Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Posts
    135
    Thanks
    1
    Thanked 0 Times in 0 Posts

    MySQL query problem again...

    $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...

    Code:
    			$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");

  • #2
    ess
    ess is offline
    Regular Coder
    Join Date
    Oct 2006
    Location
    United Kingdom
    Posts
    866
    Thanks
    7
    Thanked 30 Times in 29 Posts
    you need to write the "VALUES" keyword in your SQL Statement

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

  • #3
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •