News:

Wondering if this will always be free?  See why free is better.

Main Menu

Database Error: You have an error in your sql syntax

Started by mcmedal001, February 11, 2010, 09:58:03 AM

Previous topic - Next topic

mcmedal001

This was what i saw in my forum error log 2day. 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 " at line 3
File: /home/cynamix/public_html/Unaabjoint.net/Sources/Poll.php
Line: 178

plz what im i to do?. IS THIS A FATAL ERROR?.

Paul_Pauline

Hi.

It's not something I can help you with, but if you attach a copy of that file here i'm sure someone will be able to help you   ;)
"In every life, no matter how full or empty one's purse, there is tragedy. It is the one promise life always fulfills.
Happiness is a gift and the trick is not to expect it, but to delight in it when it comes and to add to other people's store of it."
Pauline was one of those rare people who increased the store of happiness in the world.

MrPhil

Was the complete SQL statement given as part of the error message? That would be quite useful to have. What SMF version, and what mods are installed?

If this is the section of code, and the query at fault:
$setString .= "
($row[ID_POLL], $ID_MEMBER, $id),";
}
$setString = substr($setString, 0, -1);

// Add their vote to the tally.
db_query("
INSERT IGNORE INTO {$db_prefix}log_polls
(ID_POLL, ID_MEMBER, ID_CHOICE)
VALUES $setString", __FILE__, __LINE__);


my guess is that $row[ID_POLL] and/or $ID_MEMBER and/or $id are missing a value for some reason, leaving an empty value field. That would be a bug in SMF (or any mod affecting this section) that it didn't check for undefined values. The substr call should just trim off the last trailing "," in a multi-VALUES string.

mcmedal001

Plz what should i attach to this post? MySQL or what?. And i dont use any mode on my site,  no mod at all.. But please what should i attach to here, and im using babylon theme.

MrPhil

Did you get as part of your error message something like
INSERT IGNORE INTO smf_log_polls
         (ID_POLL, ID_MEMBER, ID_CHOICE)
      VALUES (, 1375, 208)

If so, we need to see it here. The example I gave has an error in it. Given the line number you gave in your first post, that's the most likely SQL query to give an error. And again, what SMF version?

mcmedal001

This is what i latter saw in my error log, i didnt see any error like the one u posted, what i latter see is what i put below.


Invalid arguement
supplied for foreach()
File: /home/cynamix/public_html/Unaabjoint.net/Sources/poll.php
Line: 164


Im using Smf 1.1.10.  IS THIS A FATAL ERROR?

MrPhil

That's just a little "upstream" of the first error you reported.
foreach ($_REQUEST['options'] as $id)
{
$id = (int) $id;

$pollOptions[] = $id;
$setString .= "
($row[ID_POLL], $ID_MEMBER, $id),";
}
$setString = substr($setString, 0, -1);

// Add their vote to the tally.
db_query("
INSERT IGNORE INTO {$db_prefix}log_polls
(ID_POLL, ID_MEMBER, ID_CHOICE)
VALUES $setString", __FILE__, __LINE__);


Line 164 is the first ("foreach" statement). Certainly if the "foreach" statement is blowing up (because $_REQUEST['options'] is not an array), that will create a bad $setString (if it even gets that far). These may be two separate errors -- you got an SQL error before, and now you're getting a foreach error in the PHP? Or are you getting both?

mcmedal001

What should i do now? Is this a very  big problem? How do we solve the problem now?

MrPhil

You could start by answering the questions. Are you only getting the "foreach" error, or are you also getting the SQL syntax error? You must have something changed in your code, that there is no "options" array in GET or POST (no one else reports this problem). Perhaps you've been hacked? You should upgrade to 1.1.11. As you have no mods, it should be a painless process. See if your problem goes away then. If not, we can continue working on it.

mcmedal001

Its not showing thd error again does dat means that the error has been corrected?.

MrPhil

It depends on what caused the error in the first place...

If you're doing exactly the same actions as before, and no errors are generated, maybe you're in luck. If somehow the error has been corrected, without any action on your part, the only legitimate way would be if your hosting service fixed something, or restored some files. You might ask your host. On the other hand, if a hacker "fixed" their code because it's causing problems (i.e., is noticeable), that means you still have problems.

mcmedal001

The error started from a Poll, the poll has been lockd. but my site is working fine, my host didnt do anything.

JimM

If this is solved, please mark it solved by clicking the Mark Topic Solved link at the bottom left.
Jim "JimM" Moore
Former Support Specialist

Advertisement: