query error

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
nhan
Forum Commoner
Posts: 95
Joined: Sun Feb 27, 2005 8:26 pm
Contact:

query error

Post by nhan »

i have this error :

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/local/apache/login/clockout.php on line 82

$query = "select * from tbl where userName = '$user' and timeid >= (LAST_UPDATE_ID())";
$result = mysql_query($query);

//while($nt=mysql_fetch_array($result)){
while($nt=mysql_fetch_array($result)){
echo......

when i use LAST_INSERT_ID its ok but it displays all the query, i have to display the last updated row only, anyone can help...


thansk!
thegreatone2176
Forum Contributor
Posts: 102
Joined: Sun Jul 11, 2004 1:27 pm

Post by thegreatone2176 »

put the common

$result = mysql_query($query) or die(mysql_error());

and it will show you the error and if you cant figure it out paste the error here
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

LAST_UPDATE_ID() returns the last row number that was updated. What datatype is timeid in the database? Is it an integer that is autoincrementing or is it time related as the name implies?

In the meantime, try this.

Code: Select all

$query = "select * from tbl where (userName = '$user') and (timeid >= LAST_UPDATE_ID())";
edit - My bad. I got it mixed in my head with LAST_INSERT_ID()
Last edited by smpdawg on Wed Mar 02, 2005 11:14 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

LAST_UPDATE_ID() is a non existant function.
User avatar
nhan
Forum Commoner
Posts: 95
Joined: Sun Feb 27, 2005 8:26 pm
Contact:

query error

Post by nhan »

sirs,

timeid is an auto incrementing integer....
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that means nothing when LAST_UPDATE_ID() isn't a function.
User avatar
nhan
Forum Commoner
Posts: 95
Joined: Sun Feb 27, 2005 8:26 pm
Contact:

query error

Post by nhan »

but why is it when i use LAST_INSERT_ID it displays all contents of the database which satisfies the condition, is there any function that will only display the last updated row...

or better yet instead of using the function, how can i just define the value of the timeid into a variable so that ican define it as :

$query = "select * from tbl where userName = '$user' and timeid = '$timeid'";

would this be possible??

thansk!
Post Reply