Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2012
    Posts
    1

    Unanswered: Neeed help asap. SQL syntax error ..while inserting records into database

    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 ' ,, , , , 'd41d8cd98f00b204e9800998ecf8427e', , , )' at line 2

    INSERT INTO customers (fname, address, state, PostalCode, phone, email,password, movie, time, date) VALUES ( , ,, , , , 'd41d8cd98f00b204e9800998ecf8427e', , , )


    Sql code :

    $arVals['password'] = "'".md5($arVals['password'])."'";

    /************************************************** ********************************************
    Insert into the database...
    ************************************************** ********************************************/

    $query = "INSERT INTO customers (fname, address, state, PostalCode, phone, email,password, movie, time, date)
    "." VALUES (
    ".$arVals['fname'].", ".$arVals['addr1'].",".$arVals['state'].", ".$arVals['pcode']." , ".$arVals['phone'].", ".$arVals['email'].",
    ".$arVals['password'].", ".$arVals['q1'].", ".$arVals['q2'].", ".$arVals['q3'].")";


    $result = mysql_query($query) or die("Invalid query: " . mysql_error() . "<br><br>". $query);




    I cant figure out whats wrong with this ..please some one help!!

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    at a guess I'd suspect the SQL engine cannot tell the difference between sting and non string values

    string values should be encapsulated with either " or ', but probably best to use '
    Code:
    $query = "INSERT INTO customers (fname, address, state, PostalCode, phone, email,password, movie, time, date)
    "." VALUES (
    '".$arVals['fname']."', '".$arVals['addr1']."', '".$arVals['state']."', '".$arVals['pcode']."' , '".$arVals['phone']."', '".$arVals['email']."', 
    '".$arVals['password']."', '".$arVals['q1'].", ".$arVals['q2'].", ".$arVals['q3'].")";
    ...assuming q1,q2 & q3 are numeric

    were you expecting to insert a row with null values for everythign except password?
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Quote Originally Posted by anurag.sirish View Post
    I cant figure out whats wrong with this
    Well isn't that obvious when you look at this:

    Code:
    INSERT INTO customers (fname, address, state, PostalCode, phone, email,password, movie, time, date) 
    VALUES ( , ,, , , , 'd41d8cd98f00b204e9800998ecf8427e', , , )
    You need to supply at least the keyword NULL if you don't want to supply a value for a column. Please re-read the manual describing the format of an INSERT statement.
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

Posting Permissions

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