unioncraft Posted December 17, 2011 Share Posted December 17, 2011 When i try and use this app on my website i get the error, Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/unionc/public_html/auction/scripts/updateTables.php on line 15 <?php $now = time(); add_column_if_not_exist("WA_SellPrice", "seller", "VARCHAR( 255 ) NULL"); add_column_if_not_exist("WA_SellPrice", "buyer", "VARCHAR( 255 ) NULL"); add_column_if_not_exist("WA_Players", "canBuy", "INT(11) NOT NULL DEFAULT '0'"); add_column_if_not_exist("WA_Players", "canSell", "INT(11) NOT NULL DEFAULT '0'"); add_column_if_not_exist("WA_Players", "isAdmin", "INT(11) NOT NULL DEFAULT '0'"); add_column_if_not_exist("WA_Auctions", "created", "INT(11) NULL"); function add_column_if_not_exist($table, $column, $column_attr){ $exists = false; $columns = mysql_query("show columns from $table"); while($c = mysql_fetch_assoc($columns)){ if($c['Field'] == $column){ $exists = true; break; } } if(!$exists){ mysql_query("ALTER TABLE `$table` ADD `$column` $column_attr"); } } ?> Please Help! Link to comment https://forums.phpfreaks.com/topic/253347-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given/ Share on other sites More sharing options...
Pikachu2000 Posted December 17, 2011 Share Posted December 17, 2011 The query is failing and returning a boolean FALSE. mysql_error should help provide some insight as to why the query is failing. Link to comment https://forums.phpfreaks.com/topic/253347-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given/#findComment-1298724 Share on other sites More sharing options...
unioncraft Posted December 17, 2011 Author Share Posted December 17, 2011 How would i use that? Sorry, I'm new to PHP. Link to comment https://forums.phpfreaks.com/topic/253347-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given/#findComment-1298727 Share on other sites More sharing options...
requinix Posted December 17, 2011 Share Posted December 17, 2011 Step 1 would be to click the link he provided... Link to comment https://forums.phpfreaks.com/topic/253347-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given/#findComment-1298739 Share on other sites More sharing options...
unioncraft Posted December 17, 2011 Author Share Posted December 17, 2011 I did but im not sure what to do with it... Link to comment https://forums.phpfreaks.com/topic/253347-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given/#findComment-1298744 Share on other sites More sharing options...
simplypixie Posted December 17, 2011 Share Posted December 17, 2011 Are you sure you have a value assigned to your $table variable? Tray echoing it out to check. To use mysql_error, change your query to: $columns = mysql_query("show columns from $table") or die(mysql_error()); And if you can't work out (if you do get an error) from the error produced then post that error here. Link to comment https://forums.phpfreaks.com/topic/253347-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given/#findComment-1298749 Share on other sites More sharing options...
unioncraft Posted December 17, 2011 Author Share Posted December 17, 2011 Table 'unionc_auction.WA_SellPrice' doesn't exist Link to comment https://forums.phpfreaks.com/topic/253347-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given/#findComment-1298788 Share on other sites More sharing options...
simplypixie Posted December 17, 2011 Share Posted December 17, 2011 That gives you your answer (unless the table does exist) either the table name is incorrect or it doesn't exist in the database. Link to comment https://forums.phpfreaks.com/topic/253347-warning-mysql_fetch_assoc-expects-parameter-1-to-be-resource-boolean-given/#findComment-1298809 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.