Jump to content

Resource Boolean Error


unemployment

Recommended Posts

I created this function to update my tour system.  The query is working and is updating one row in the table, but I get a resource boolean error in the return section of the function.  Any idea why?

 

function update_tour($uid, $step)
{
$step 	= (int)$step;
$uid	= (int)$uid;

$sql =	"UPDATE `users`
		SET
			`tour_step` = ${step}
		WHERE `id` = '${uid}'";

$q = mysql_query($sql) or die(mysql_error());

return (mysql_num_rows($q) === 1) ? mysql_result($q, 0): false;
}

Link to comment
https://forums.phpfreaks.com/topic/255143-resource-boolean-error/
Share on other sites

UPDATE queries don't return result resources.

 

mysql_num_rows and mysql_result are only used with SELECT, SHOW, and EXPLAIN queries that return result resources.

 

UPDATE and INSERT (REPLACE) queries return either TRUE (the query executed without any errors) or FALSE (the query failed due to an error.) You can use mysql_affected_rows to determine if UPDATE and INSERT (REPLACE) queries actually change any rows.

 

Have you actually read any of the php.net documentation for the php functions you are using? That's where all the information that I just posted was learned.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.