Jump to content

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


Recommended Posts

[size=20pt]SOLVED[/size]




im getting the following error...

[quote]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[/quote]

i located that error to..

[code]       
$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());[/code]

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?
I'm not an expert but in this statement:

[quote]$sqlUser = "Select username,Account from users where id='$userid'";[/quote]

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.
[quote author=simcoweb link=topic=101817.msg403271#msg403271 date=1153845927]
I'm not an expert but in this statement:

[quote]$sqlUser = "Select username,Account from users where id='$userid'";[/quote]

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.
[/quote]

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!?

[quote]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[/quote]
where the query is...
[code]        $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__);[/code]

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
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 :)

[url=http://dev.mysql.com/doc/refman/4.1/en/select.html]http://dev.mysql.com/doc/refman/4.1/en/select.html[/url]
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

[code]SELECT username FROM membersTable WHERE userid = '1'[/code]
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
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:

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

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.
[quote author=simcoweb link=topic=101817.msg403316#msg403316 date=1153849234]
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:

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

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.
[/quote]

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
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.