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

Link to comment
Share on other sites

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.