Jump to content


Photo

Confused, mysql_error() not returning query it is conected to, but another query


  • Please log in to reply
8 replies to this topic

#1 leeming

leeming
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts

Posted 25 July 2006 - 04:16 PM

SOLVED




im getting the following error...

Error: please report to an admin XX:01 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 'Select `numb` from `games` where `db` = 'worldwar_game6'' at li


i located that error to..

        
$sqlUser = "Select username,Account from users where id='$userid'";
$rUser = mysql_query($sqlUser,$dbh) or die("Error: please report to an admin XX:01 ".mysql_error());

yet the above sql query doesnt contain the query given in the mysql_error...

the $dbh, is a conection, with or die's conected to them, and i have checked these, and they are not them... also i have searched pages conected to this page, for the query given in the mysql_error, which i found 1 or 2 on other pages, and give them a diferent 'or die' message... yet the error message is still the "XX:01" which is the above code...

is mysql_error() some how returning an OLD error?
Im not perfect ;) lol

#2 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 25 July 2006 - 04:45 PM

I'm not an expert but in this statement:

$sqlUser = "Select username,Account from users where id='$userid'";


I've never used a comma in the query string. The one you have after 'username'. Remove that, put a space there, and try again.

#3 leeming

leeming
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts

Posted 25 July 2006 - 04:51 PM

I'm not an expert but in this statement:

$sqlUser = "Select username,Account from users where id='$userid'";


I've never used a comma in the query string. The one you have after 'username'. Remove that, put a space there, and try again.


good suggestion, it actully did do some thing (didnt fix it, got a 2nd error, im gonna work on now)... as for the comma thing u said.. new or not to sql (? i dont know, but will explain)...

instead of using, "SELECT * FROM....", '*' been the 'all' fields selected... instead i just SELECT the 2 fields username and account...



*edit*
urm, well i still cant seem to debug this at all, due to the mysql_error not returning the correct query!?

Error: please report to an admin XX:01 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 'worldwar_game6''' at line 1::18

where the query is...
        $sqlUser1 = "Select username, Account from users where id='$userid'";
        $rUser = mysql_query($sqlUser1,$dbh) or die("Error: please report to an admin XX:01 ".mysql_error($dbh)."::".__LINE__);

a little bit changed from the orginal.. like added __LINE__ just to double check it was the same line where i was looking... also tried mysql_error() with arguments (2 conections that are availible, $dbh and $dbh000) but no improvement.... urm and also searched for them other querys that had the same sql info in, and checked them for errors (the error returned shows a tripple ' single quote)

now that it seems that this error is not for the query it is attacheched to... how can i go about finding out which query it is going on about
Im not perfect ;) lol

#4 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 25 July 2006 - 05:13 PM

What's the new error? That could possibly resolve it further.

In regards to the Select statement, once again i'm a noobster, but looking at the syntax in the MySQL manual there's either a space or some sort of operator between the query commands ( ie: the '*' for example). Otherwise it's pretty much like this:

$sqlUser = "SELECT FROM users (username, Account) WHERE id='$userid'";

This reference link might help :)

http://dev.mysql.com.../en/select.html

#5 leeming

leeming
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts

Posted 25 July 2006 - 05:24 PM

see above edit...

as for the sql you said... 2 my knowledge, i have never seen it wrote like that... (does it work?)
*any one else doesnt need to read down wards*


normaly its some thing like this for a query

SELECT username FROM membersTable WHERE userid = '1'
that would look up ur members.. find member id 1.. and only get the user name... using '*' means all fields, and using commas ',' for selecting more than 1 field
Im not perfect ;) lol

#6 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 25 July 2006 - 05:40 PM

Heh..like I said..i'm a noob. Using the forums to learn more.

Ok, a couple of things. Your last query example is correct. I think I was focusing on the comma separating the two fields and the lack of a space between the comma and the second field name.  I honestly don't know if that makes  a diff or not but what was being reported was a syntax error. Here's the example I use:

$query = "SELECT b_name, b_author, b_cat, b_price from lib where id='" . $book_id . "'";


Noting the list of fields, the comma, then the space to separate. It's just a thought. But why you're getting an error unrelated to this query is strange. Unless you have a second query statement in your code.

#7 leeming

leeming
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts

Posted 25 July 2006 - 05:45 PM

Heh..like I said..i'm a noob. Using the forums to learn more.

Ok, a couple of things. Your last query example is correct. I think I was focusing on the comma separating the two fields and the lack of a space between the comma and the second field name.  I honestly don't know if that makes  a diff or not but what was being reported was a syntax error. Here's the example I use:

$query = "SELECT b_name, b_author, b_cat, b_price from lib where id='" . $book_id . "'";


Noting the list of fields, the comma, then the space to separate. It's just a thought. But why you're getting an error unrelated to this query is strange. Unless you have a second query statement in your code.


the file im using, is included with another file (thus why i checked the other files aswell)... i even changed the name of the SQL (before the mysql_query part) just incase there was a mix with vearibles (not that it should matter, but im trying every thing lol)

can some one who is experianced please even read this post lol
Im not perfect ;) lol

#8 leeming

leeming
  • Members
  • PipPipPip
  • Advanced Member
  • 93 posts

Posted 25 July 2006 - 05:52 PM

FIXED... i compared it to a backed up version (thank god lol).... i had left a tag open, right at the begginning of the code
Im not perfect ;) lol

#9 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 25 July 2006 - 06:05 PM

Ahhh yes...the simple missing ;  I've had that as well. Glad you found it!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users