w424637 Posted March 12, 2013 Share Posted March 12, 2013 Help please - I have a simple page which errors with: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in If I remove the Second Query and Output section it works also If I remove the First Query and Output section it works However both together and it fails at the line while($row=mysql_fetch_array($new2)) Why is this - drivign me nuts <?php require_once ('connection.php'); //First Query and Output $result = mysql_query("CALL C01_Client_Summary_ByAccount(1, '2012-02-27', '2013-03-29');"); while($row=mysql_fetch_array($result)) { echo $row['CommisionPercentage']; } //END First Query and Output //Second Query and Output $new2 = mysql_query("CALL C01_Client_Summary_ByBetType(1, '2012-02-27', '2013-03-29');"); while($row=mysql_fetch_array($new2)) { echo $row['Turnover']; } //END Second Query and Output ?> Link to comment https://forums.phpfreaks.com/topic/275567-error-on-simple-2-query-page/ Share on other sites More sharing options...
cutielou22 Posted March 14, 2013 Share Posted March 14, 2013 Try: require_once ('connection.php'); //First Query and Output $result = mysql_query("CALL C01_Client_Summary_ByAccount(1, '2012-02-27', '2013-03-29');"); while($row=mysql_fetch_array($result)) { echo $row['CommisionPercentage']; } //END First Query and Output //Second Query and Output $new2 = mysql_query("CALL C01_Client_Summary_ByBetType(1, '2012-02-27', '2013-03-29');"); while($row2=mysql_fetch_array($new2)) { echo $row2['Turnover']; } //END Second Query and Output I changed the 2nd query's variable by adding a "2" behind it. Link to comment https://forums.phpfreaks.com/topic/275567-error-on-simple-2-query-page/#findComment-1418514 Share on other sites More sharing options...
Psycho Posted March 14, 2013 Share Posted March 14, 2013 The variable names are the problem since they should be overwritten in those scenarios. Besides, the error given by PHP is . . . Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given That means the query failed. You are calling a stored procedure twice with the same parameters. not knowing what that stored procedure is it is impossible to know if that is correct or not. but, you can help yourslef out by checking the actual error from mysql <?php require_once ('connection.php'); //First Query and Output $query = "CALL C01_Client_Summary_ByAccount(1, '2012-02-27', '2013-03-29');"; $result = mysql_query() or die("Query: $query<br>Error: " .mysql_error()); while($row=mysql_fetch_array($result)) { echo $row['CommisionPercentage']; } //END First Query and Output //Second Query and Output $query = "CALL C01_Client_Summary_ByAccount(1, '2012-02-27', '2013-03-29');"; $result = mysql_query() or die("Query: $query<br>Error: " .mysql_error()); while($row=mysql_fetch_array($result)) { echo $row['Turnover']; } //END Second Query and Output ?> Link to comment https://forums.phpfreaks.com/topic/275567-error-on-simple-2-query-page/#findComment-1418520 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.