| View previous topic :: View next topic |
| Author |
Message |
Colocation Site Admin

Joined: Jan 07, 2004 Posts: 404
|
Posted: Thu Nov 11, 2004 7:58 am Post subject: User Error |
|
|
When logged out of a particular nuke site this error appears for a forum topic.
| Code: |
Could not obtain user vote data for this topic
DEBUG MODE
SQL Error : 1064 You have an error in your SQL syntax near '' at line 4
SELECT vote_id FROM nuke_bbvote_voters WHERE vote_id = 15 AND vote_user_id =
Line : 744
File : /usr/www/virtual/widjets/www.widjets.com/modules/Forums/viewtopic.php |
When logged in there is no error. |
|
| Back to top |
|
 |
Humpa Site Admin

Joined: Feb 05, 2004 Posts: 23
|
Posted: Thu Nov 11, 2004 10:47 am Post subject: |
|
|
Turn off debug mode.
Or, find the line mentioned in the error with "AND vote_user_id = "
Find that and put single quotes around the variable after "AND vote_user_id = " |
|
| Back to top |
|
 |
Colocation Site Admin

Joined: Jan 07, 2004 Posts: 404
|
Posted: Thu Nov 11, 2004 11:05 am Post subject: Constants |
|
|
I found that the DEBUG mode is switched off in /includes/constants.php
That solved the error which now reads:
| Quote: |
| Could not obtain user vote data for this topic |
Which presumably means that the poll is a registered user one only? |
|
| Back to top |
|
 |
Colocation Site Admin

Joined: Jan 07, 2004 Posts: 404
|
Posted: Fri Nov 12, 2004 10:41 am Post subject: Code |
|
|
I found this:
| Code: |
$sql = "SELECT vote_id
FROM " . VOTE_USERS_TABLE . "
WHERE vote_id = $vote_id
AND vote_user_id = " . $userdata['user_id'];
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, "Could not obtain user vote data for this topic", '', __LINE__, __FILE__, $sql);
} |
Is there not single quotes already?
Surely the poll needs to be visable regardless of being logged in or out? |
|
| Back to top |
|
 |
Humpa Site Admin

Joined: Feb 05, 2004 Posts: 23
|
Posted: Fri Nov 12, 2004 11:06 am Post subject: |
|
|
I have no idea as to the actual purpose of this piece of code. Not sure at all about what the real problem is. I am not familar with the Forums code, so I do not know what this code is actually doing.
Adding the single quotes is not the solution - at least I assume it is not the solution. But, adding the single quotes will get rid of this particular error. I don't know if the code is functioning correctly, for I dont know what it is supposed to do in the first place.
But, to add the single quotes you have to know some php code or you will not know how to add in the single quotes.
Here is that bit of code with single quotes inserted:
| Code: |
$sql = "SELECT vote_id
FROM " . VOTE_USERS_TABLE . "
WHERE vote_id = $vote_id
AND vote_user_id = '" . $userdata['user_id']."'"; |
|
|
| Back to top |
|
 |
Colocation Site Admin

Joined: Jan 07, 2004 Posts: 404
|
Posted: Fri Nov 12, 2004 11:23 am Post subject: Working |
|
|
That fixed the problem.
The problem was this.
In the forums where a user had set up a poll, the above error was being displayed. Essentially, restricting access to a guest user. The poll was visable to a logged-in user however.
Thanks, works great now. |
|
| Back to top |
|
 |
|