unemployment Posted January 16, 2012 Share Posted January 16, 2012 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; } Quote Link to comment https://forums.phpfreaks.com/topic/255143-resource-boolean-error/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 16, 2012 Share Posted January 16, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/255143-resource-boolean-error/#findComment-1308180 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.