zero_ZX Posted October 23, 2010 Share Posted October 23, 2010 Hi, I receive the following error(s): Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\intra\VVS\admin2\orders.php on line 294 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\intra\VVS\admin2\orders.php on line 301 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\intra\VVS\admin2\orders.php on line 294 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\intra\VVS\admin2\orders.php on line 301 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\intra\VVS\admin2\orders.php on line 294 Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\intra\VVS\admin2\orders.php on line 301 This is my code: <?PHP $result = mysql_query("SELECT * FROM orders ORDER BY deadline"); while($row = mysql_fetch_array($result)) { $info = mysql_query("SELECT * FROM clients WHERE id='".$row['requester']."'"); $inforow = mysql_fetch_array( $info ); echo ' <td><a href="client-edit.php?id=' . $row["requester"] .'"> ' . $inforow["company"] . ' </a></td> <td> <a class="btn_no_text btn ui-state-default ui-corner-all tooltip" title="Telefon: ' . $inforow["phone"] . '"> <span class="ui-icon ui-icon-comment"></span> <a class="btn_no_text btn ui-state-default ui-corner-all tooltip" title="Kontakt: ' . $inforow["contact"] . '"> <span class="ui-icon ui-icon-person"></span> <a class="btn_no_text btn ui-state-default ui-corner-all tooltip" title="Email: ' . $inforow["email"] . '"> <span class="ui-icon ui-icon-mail-closed"></span> <a class="btn_no_text btn ui-state-default ui-corner-all tooltip" title="Adresse: ' . $inforow["address"] . '"> <span class="ui-icon ui-icon-home"></span> </td> <td><a href="order-view.php?id=' . $row["id"] .'">' . $row["title"] . ' </a></td> '; if ($row["approved"] == "0") { echo' <td><a class="btn_no_text btn ui-state-default ui-corner-all tooltip" title="Denne anmodning er ikke godkendt af en formand"><span class="ui-icon ui-icon-closethick"></span></a> </td> '; } else { echo' <td><a class="btn_no_text btn ui-state-default ui-corner-all tooltip" title="Denne anmodning er godkendt af en formand"><span class="ui-icon ui-icon-check"></span></a> </td>'; } if ($row["status"] == "0") { echo' <td><a class="btn_no_text btn ui-state-default ui-corner-all tooltip" title="Denne bestilling er ikke behandlet"><span class="ui-icon ui-icon-flag"></span></a> </td> '; } elseif ($row["status"] == "1") { echo' <td><a class="btn_no_text btn ui-state-default ui-corner-all tooltip" title="Denne bestilling er under behandling"><span class="ui-icon ui-icon-transferthick-e-w"></span></a> </td>'; } elseif ($row["status"] == "2") { echo' <td><a class="btn_no_text btn ui-state-default ui-corner-all tooltip" title="Denne bestilling er færdig behandlet"><span class="ui-icon ui-icon-cart"></span></a> </td>'; } $info2 = mysql_query("SELECT * FROM clients WHERE id='".$row['requester']."'"); $inforow2 = mysql_fetch_array( $info2 ); $info4 = mysql_query("SELECT * FROM slaves WHERE id='".$row['slave']."'"); $inforow4 = mysql_fetch_array( $info4 ); echo' <td>' . $inforow2["username"] . '</td> <td>' . $inforow4["name"] . '</td> <td>' . $row["deadline"] . '</td>'; $info3 = mysql_query("SELECT * FROM invoices WHERE order='".$row['id']."'"); $inforow3 = mysql_fetch_array( $info3 ); //Yay! We found an invoice if(mysql_num_rows($info3)>0) { The problems appears here: (last line) if(mysql_num_rows($info3)>0) Basically, i want the queries to detect if there's an invoice created for this order already. So i use this: $result = mysql_query("SELECT * FROM orders ORDER BY deadline"); while($row = mysql_fetch_array($result)) $info3 = mysql_query("SELECT * FROM invoices WHERE order='".$row['id']."'"); $inforow3 = mysql_fetch_array( $info3 ); //Yay! We found an invoice if(mysql_num_rows($info3)>0) Any help is much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/216657-mysql_num_rows/ Share on other sites More sharing options...
Pikachu2000 Posted October 23, 2010 Share Posted October 23, 2010 The queries are failing and returning boolean FALSE to mysql_num_rows(). Quote Link to comment https://forums.phpfreaks.com/topic/216657-mysql_num_rows/#findComment-1125662 Share on other sites More sharing options...
zero_ZX Posted October 23, 2010 Author Share Posted October 23, 2010 Correct, but I don't know why.. It seems right to me :/ Quote Link to comment https://forums.phpfreaks.com/topic/216657-mysql_num_rows/#findComment-1125668 Share on other sites More sharing options...
PFMaBiSmAd Posted October 23, 2010 Share Posted October 23, 2010 If you echo mysql_error(); it will tell you why any query is failing. For one of the queries, you will find that order is a reserved mysql keyword (as in ORDER BY). You should either rename your order column to something else or you must enclose it in back-ticks `` every time you use it in a query. Quote Link to comment https://forums.phpfreaks.com/topic/216657-mysql_num_rows/#findComment-1125670 Share on other sites More sharing options...
Pikachu2000 Posted October 23, 2010 Share Posted October 23, 2010 How can you tell? You have no logic in place to catch/log/report any errors. Remove the query strings from the execution statements, Store them in variables and add error reporting, as below. $query3 = "SELECT * FROM invoices WHERE order='".$row['id']."'"; $info3 = mysql_query($query3) or die( '<br>$query3 string: ' . $query3 . '<br>cratered with error: ' . mysql_error() . '<br>'); $inforow3 = mysql_fetch_array( $info3 ); //Yay! We found an invoice if(mysql_num_rows($info3)>0) Quote Link to comment https://forums.phpfreaks.com/topic/216657-mysql_num_rows/#findComment-1125671 Share on other sites More sharing options...
zero_ZX Posted October 23, 2010 Author Share Posted October 23, 2010 Okay, i tried both your suggestions: $result = mysql_query("SELECT * FROM `orders` ORDER BY deadline" ); and $query3 = mysql_query("SELECT * FROM invoices WHERE `order`='".$row['id']."'"); $info3 = mysql_query($query3) or die( '<br>$query3 string: ' . $query3 . '<br>cratered with error: ' . mysql_error() . '<br>'); $inforow3 = mysql_fetch_array( $info3 ); Returns: $query3 string: Resource id #11 cratered with error: Quote Link to comment https://forums.phpfreaks.com/topic/216657-mysql_num_rows/#findComment-1125675 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.