yourichi Posted August 11, 2011 Share Posted August 11, 2011 Hi guys, I appreciate this is just a common error, ive searched through an found many threads with the same error and tried using the mysql error func but it was of no joy, Im still fairly fresh to php itself, but im fairly familar with C structures in general, i think im just being blind on what im doing. trying to create a function to be called that will basically reduce the number of coins one individual person has. ensuring they have enough credit available. (im aware there are other more individual ways of doing this as per shop/pricing but it doesnt particularly fit with the bigger scheme of things to what im trying to achieve hence a seperate function for just reducing the coin count by 50 is what im after. function purchasebox() { list($coin1) = mysql_fetch_row(mysql_query("select coin from users where id='$_SESSION[user_id]'")); if ($coin1> '49') { $newcoin = $coin1 - '50'; mysql_fetch_row(mysql_query("UPDATE sdaccount.users SET coin ='$newcoin' WHERE id='$_SESSION[user_id]'")); echo "Successfully bought!"; } else { echo "Not enough coins"; } } Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\supreme\dbc.php on line 172 Box successfully bought! mysql_fetch_row(mysql_query("UPDATE sdaccount.users SET coin ='$newcoin' WHERE id='$_SESSION[user_id]'")); is line 172 Thanks for any help, im sure its so stupidly obvious what ive done lol, im just having a very long blonde moment >.<! Regards. Edit: One thing to be noted, it is actually working as far as I can see, It is updating the correct person's coin, and follows the rule of more than 50. and will subtract 50 if they have sufficient coin. So it appears to work, its just not clear why its giving this error. Quote Link to comment https://forums.phpfreaks.com/topic/244524-warning-mysql_fetch_row-expects-parameter-1-to-be-resource-boolean-given-in/ Share on other sites More sharing options...
yourichi Posted August 11, 2011 Author Share Posted August 11, 2011 Think i fixed this, i did a little more reading, i was having a severe blonde moment, apparently i was mis-using the mysql_query in the second query line (172) I was doing another fetch which is supposed to return a resource, where as for an update i need to be requesting boolean. >feels stupid for no realizing how sloppy that coding was grmbl< Quote Link to comment https://forums.phpfreaks.com/topic/244524-warning-mysql_fetch_row-expects-parameter-1-to-be-resource-boolean-given-in/#findComment-1256021 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.