not sure what i'm doing wrong...

Discussion in 'MySQL' started by Greenmethod, Aug 8, 2007.

  1. #1
    I am trying to insert some data into a database, and am getting
    "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 'Pawn_Num='1', Pawn_Port='LW3', Pawn_Path='\\\\PS1\\LPT1', Pawn_Mod='', Rec_Num='' at line 1"

    My code is as follows:

    mysql_query("INSERT INTO printers SET cust_no='$cust_no' Pawn_Num='$Pawn_Num', Pawn_Port='$Pawn_Port', Pawn_Path='$Pawn_Path', Pawn_Mod='$Pawn_Mod', Rec_Num='$Rec_Num', Rec_Port='$Rec_Port', Rec_Path='$Rec_Path', Rec_Mod='$Rec_Mod', Rep_Num='$Rep_Num', Rep_Port='$Rep_Port', Rep_Path='$Rep_Path', Rep_Mod='$Rep_Mod', Lab_Num='$Lab_Num', Lab_Port='$Lab_Port', Lab_Path='$Lab_Path', Lab_Mod='$Lab_Mod', Jew_Num='$Jew_Num', Jew_Port='$Jew_Port', Jew_Path='$Jew_Path', Jew_Mod='$Jew_Mod'") or die(mysql_error());
    PHP:
    does anyone have any idea what i'm doing wrong here? Thanks in advance!
     
    Greenmethod, Aug 8, 2007 IP
  2. JZWolf

    JZWolf Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    check the value of these parameters.
     
    JZWolf, Aug 8, 2007 IP
  3. The Webmaster

    The Webmaster IdeasOfOne

    Messages:
    9,516
    Likes Received:
    718
    Best Answers:
    0
    Trophy Points:
    360
    #3
    What are you passing as $Rec_Num ?
    Try and check the value for special char like " ' , etc..
     
    The Webmaster, Aug 10, 2007 IP
  4. cpucandy

    cpucandy Peon

    Messages:
    489
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You seem to be missing a comma after set cust_no = '$cust_no'
     
    cpucandy, Aug 12, 2007 IP
    The Webmaster likes this.
  5. dailwap

    dailwap Banned

    Messages:
    100
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    i think

    the best possibility is that you should check the structure of your database

    please check whthere the name is correct

    hope this helps

    /d
     
    dailwap, Aug 13, 2007 IP
  6. Kuldeep1952

    Kuldeep1952 Active Member

    Messages:
    290
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #6
    My suggestion is that you assign the SQL to a string, echo the string, and then try to run the
    generated SQL in phpmyadmin. You may thus be able to diagnose the problem more easily.

    $sqlstring ="INSERT INTO printers SET cust_no='$cust_no' ...";
    echo $sqlstring;
    die();
     
    Kuldeep1952, Aug 14, 2007 IP
  7. The Webmaster

    The Webmaster IdeasOfOne

    Messages:
    9,516
    Likes Received:
    718
    Best Answers:
    0
    Trophy Points:
    360
    #7
    You hit it right on the head with a titanium nail..
    Yeah that must be the reason of the error..
     
    The Webmaster, Aug 14, 2007 IP