Closed Thread
Results 1 to 7 of 7

Thread: Query error - SQL Syntax

  1. #1
    Devana is offline Newbie
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Query error - SQL Syntax

    I'm working on a new website and was about to add some items via my admin panel, and I got this error:

    QUERY 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 ',0, '1', 'a:4:{s:4:\"stat\";s:6:\"energy\";s:3:\"dir\";s:3: \"pos\";s:8:\"inc_typ' at line 1
    Query was INSERT INTO items VALUES('',1,'gkh','1451',,,0, '1', 'a:4:{s:4:\"stat\";s:6:\"energy\";s:3:\"dir\";s:3: \"pos\";s:8:\"inc_type\";s:7:\"percent\";s:10:\"in c_amount\";i:50;}', '0', 'a:4:{s:4:\"stat\";s:6:\"energy\";s:3:\"dir\";s:3: \"pos\";s:8:\"inc_type\";s:6:\"figure\";s:10:\"inc _amount\";i:0;}', '0', 'a:4:{s:4:\"stat\";s:6:\"energy\";s:3:\"dir\";s:3: \"pos\";s:8:\"inc_type\";s:6:\"figure\";s:10:\"inc _amount\";i:0;}', 0, 0)
    The error should be here, somewhere:

    Code:
    $itmname=$_POST['itmname'];$itmdesc=$_POST['itmdesc'];$weapon=abs((int) $_POST['weapon']);$armor=abs((int) $_POST['armor']);if($_POST['itmbuyable'] == 'on') { $itmbuy=1; } else { $itmbuy=0; }$db->query("DELETE FROM items WHERE itmid={$_POST['itmid']}",$c);$efx1=$db->escape(serialize(array("stat" => $_POST['effect1stat'], "dir" => $_POST['effect1dir'], "inc_type" => $_POST['effect1type'], "inc_amount" => abs((int) $_POST['effect1amount']))));$efx2=$db->escape(serialize(array("stat" => $_POST['effect2stat'], "dir" => $_POST['effect2dir'], "inc_type" => $_POST['effect2type'], "inc_amount" => abs((int) $_POST['effect2amount']))));$efx3=$db->escape(serialize(array("stat" => $_POST['effect3stat'], "dir" => $_POST['effect3dir'], "inc_type" => $_POST['effect3type'], "inc_amount" => abs((int) $_POST['effect3amount']))));$m=$db->query("INSERT INTO items VALUES('{$_POST['itmid']}',{$_POST['itmtype']},'$itmname','$itmdesc',{$_POST['itmbuyprice']},{$_POST['itmsellprice']},$itmbuy, '{$_POST['effect1on']}', '$efx1', '{$_POST['effect2on']}', '$efx2', '{$_POST['effect3on']}', '$efx3', $weapon, $armor)");print "The {$_POST['itmname']} Item was edited successfully.";stafflog_add("Edited item {$_POST['itmname']}");} 
    Could anyone please help me locate the problem?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    LiLMsNinja's Avatar
    LiLMsNinja is offline Learning Programmer
    Join Date
    May 2008
    Posts
    42
    Rep Power
    0

    Re: Query error - SQL Syntax

    There's some values not getting passed into the query...

    Query was INSERT INTO items VALUES('',1,'gkh','1451',,,0, '1', 'a:4:{s:4


    You need to pass something between these commas.

  4. #3
    Devana is offline Newbie
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Re: Query error - SQL Syntax

    Quote Originally Posted by LiLMsNinja View Post
    There's some values not getting passed into the query...

    Query was INSERT INTO items VALUES('',1,'gkh','1451',,,0, '1', 'a:4:{s:4


    You need to pass something between these commas.
    Maybe a stupid question, but how do I do that?

  5. #4
    LiLMsNinja's Avatar
    LiLMsNinja is offline Learning Programmer
    Join Date
    May 2008
    Posts
    42
    Rep Power
    0

    Re: Query error - SQL Syntax

    The thing is i don't know PHP... so you'll have to find the spot where you are trying to pass a value into those locations of the query and fix it. Either by adding exception handling where if no value is needed then remove the comma. Or, by populating NULL between the commas.

  6. #5
    Devana is offline Newbie
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Re: Query error - SQL Syntax

    Thanks for the tips. I'll test a little and see what happens. If anyone else has some ideas or something more concrete, please let me know. Thanks :-)

  7. #6
    LiLMsNinja's Avatar
    LiLMsNinja is offline Learning Programmer
    Join Date
    May 2008
    Posts
    42
    Rep Power
    0

    Re: Query error - SQL Syntax

    You're going to have to post moar code if you want something more concrete. Try the PHP forums.

  8. #7
    Devana is offline Newbie
    Join Date
    Sep 2009
    Posts
    4
    Rep Power
    0

    Re: Query error - SQL Syntax

    Problem fixed. Thanks for the help

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [help]Parse error: syntax error, unexpected $end
    By kiddies in forum PHP Development
    Replies: 3
    Last Post: 07-18-2010, 02:58 PM
  2. Possible Syntax Error.
    By ImTheMessenger in forum Python
    Replies: 3
    Last Post: 01-22-2010, 08:40 PM
  3. Odd syntax error?
    By akashhsaka in forum Python
    Replies: 6
    Last Post: 05-22-2009, 03:29 PM
  4. Syntax error
    By Jaan in forum PHP Development
    Replies: 6
    Last Post: 01-17-2008, 09:42 AM
  5. SQL syntax error
    By reachpradeep in forum Database & Database Programming
    Replies: 2
    Last Post: 10-11-2007, 09:29 AM

Tags for this Thread

Bookmarks

Posting Permissions

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