Page 1 of 1

query error

Posted: Wed Mar 02, 2005 10:39 pm
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!

Posted: Wed Mar 02, 2005 10:49 pm
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

Posted: Wed Mar 02, 2005 11:05 pm
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()

Posted: Wed Mar 02, 2005 11:14 pm
by feyd
LAST_UPDATE_ID() is a non existant function.

query error

Posted: Wed Mar 02, 2005 11:25 pm
by nhan
sirs,

timeid is an auto incrementing integer....

Posted: Wed Mar 02, 2005 11:26 pm
by feyd
that means nothing when LAST_UPDATE_ID() isn't a function.

query error

Posted: Wed Mar 02, 2005 11:36 pm
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!