doucie Posted April 15, 2007 Share Posted April 15, 2007 Hi All, I ge the error message below from the code further down. Line 19 is while($debt_history=mysqli_fetch_array($result)){ Thanks All. By the way how do I get code to appear in color like on other posts? Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\wamp\www\reporting\debt_report.php on line 19 <?php //get debt history and display in table function get_debt_history() { $db=mysqli_connect('localhost','root','','debtnet'); if(mysqli_connect_errno()) { echo 'Could not connect to the database'; exit; } $query="SELECT * FROM history WHERE cdebtref=$debtref"; $result=mysqli_query($db,$query); while($debt_history=mysqli_fetch_array($result)){ echo "<table><tr><td>{$debt_history['cnotes']}</td></tr>"; echo "<table><tr><td>{$debt_history['cusercode']}</td></tr>"; echo "<table><tr><td>{$debt_history['cactiontype']}</td></tr>"; echo "<table><tr><td>{$debt_history['debalance']}</td></tr>"; echo "<table><tr><td>{$debt_history['ihistoryid']}</td></tr></table>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/ Share on other sites More sharing options...
ignace Posted April 15, 2007 Share Posted April 15, 2007 <?PHP $result=mysqli_query($db,$query); if (is_resource($result)) { // Check result first echo "<table border="0">"; // We start the table while($debt_history=mysqli_fetch_array($result)){ echo "tr><td>{$debt_history['cnotes']}</td></tr>"; echo "<tr><td>{$debt_history['cusercode']}</td></tr>"; echo "<tr><td>{$debt_history['cactiontype']}</td></tr>"; echo "<tr><td>{$debt_history['debalance']}</td></tr>"; echo "<tr><td>{$debt_history['ihistoryid']}</td></tr>"; } echo "</table>"; // We close the table } ?> p.s.: use code tags, you can add them by pressing on the # then paste your code and hit it again to close the code tags! Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-229749 Share on other sites More sharing options...
doucie Posted April 15, 2007 Author Share Posted April 15, 2007 Nothing displayed. No error message though! I take it the is_resource just checks that there is a result? Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-229812 Share on other sites More sharing options...
neel_basu Posted April 15, 2007 Share Posted April 15, 2007 Value of $result is False something is wrong in your mysqli_query And why you guys use mysqli ???????????????? A big Question Mark. mysql is good and Supported by most of the host Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-229833 Share on other sites More sharing options...
doucie Posted April 15, 2007 Author Share Posted April 15, 2007 OK, I thought there might be something wrong with the query so I changed it to the simplest one there is. The strange thing is that my <div> expands as if filled with lots of data but none of it is visible!!??!!? <?php //get debt history and display in table function get_debt_history() { $db=mysqli_connect('localhost','root','','debtnet'); if(mysqli_connect_errno()) { echo 'Could not connect to the database'; exit; } $query="SELECT * FROM history"; $result=mysqli_query($db,$query); echo "<table>"; while($debt_history=mysqli_fetch_array($result)){ echo "<tr><td>{$debt_history['cactiontime']}</td></tr>"; echo "<tr><td>{$debt_history['creference']}</td></tr>"; echo "<tr><td>{$debt_history['ilocationid']}</td></tr>"; echo "<tr><td>{$debt_history['cnotes']}</td></tr>"; echo "<tr><td>{$debt_history['cpaymenttype']}</td></tr>"; } echo "</table>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-229840 Share on other sites More sharing options...
ignace Posted April 15, 2007 Share Posted April 15, 2007 change your div into the following: <div style="position:relative;"> Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-229842 Share on other sites More sharing options...
doucie Posted April 15, 2007 Author Share Posted April 15, 2007 Not sure how that'll help. I've got rid of the div entirely. Same thing happens. A long page with no visible data Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-229846 Share on other sites More sharing options...
doucie Posted April 15, 2007 Author Share Posted April 15, 2007 I've tried changing the div as you have suggested and also tried without a div and also just for good measure on a different page. Same result every time. A long page as if the data is there but no visible data. Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-229868 Share on other sites More sharing options...
doucie Posted April 16, 2007 Author Share Posted April 16, 2007 Can anyone else help with this please, I'm really stuck? Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-230430 Share on other sites More sharing options...
neel_basu Posted April 16, 2007 Share Posted April 16, 2007 Its Highly Recomended That YOu Use mysql Not mysqli Instaed Of while($debt_history=mysqli_fetch_array($result)){ echo "<tr><td>{$debt_history['cactiontime']}</td></tr>"; echo "<tr><td>{$debt_history['creference']}</td></tr>"; echo "<tr><td>{$debt_history['ilocationid']}</td></tr>"; echo "<tr><td>{$debt_history['cnotes']}</td></tr>"; echo "<tr><td>{$debt_history['cpaymenttype']}</td></tr>"; } Try this echo mysql_result($result, 2); Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-230460 Share on other sites More sharing options...
neel_basu Posted April 16, 2007 Share Posted April 16, 2007 The mysqli extension allows you to access the functionality provided by MySQL 4.1 and above. More information about the MySQL Database server can be found at » http://www.mysql.com/ If Your server Doesn't Support that or > that version of MySQl your code wouldn't work Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-230463 Share on other sites More sharing options...
doucie Posted April 16, 2007 Author Share Posted April 16, 2007 Hi neel_basu, I'm a bit confused by your 2nd from last post. Should I be replacing all the mysqli's with mysql? Also where should the echo mysql_result($result, 2); go? Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-230540 Share on other sites More sharing options...
doucie Posted April 16, 2007 Author Share Posted April 16, 2007 I've got other queries working fine with mysqli so it can't be that. Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-230557 Share on other sites More sharing options...
per1os Posted April 16, 2007 Share Posted April 16, 2007 $result=mysqli_query($db,$query) or DIE(mysqli_error()); Try that, chances are it is your query that is bad. If that does not work print out the $query and run that in phpMyAdmin and make sure that the query is doing what it is suppose to do. Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-230560 Share on other sites More sharing options...
doucie Posted April 16, 2007 Author Share Posted April 16, 2007 As you can see the query is very simple, there is tons of data in the table. I've checked via PHPmyAdmin an via the zend ide i'm working in. The strange thing is the div expands as if the data is there but it is isn't. Its doing my bleedin head in now. <?php //get debt history and display in table function get_debt_history() { $db=mysqli_connect('localhost','root','','debtnet'); if(mysqli_connect_errno()) { echo 'Could not connect to the database'; exit; } $query="SELECT * FROM history"; $result=mysqli_query($db,$query) or DIE(mysqli_error()); echo "<table>"; while($debt_history=mysqli_fetch_array($result)){ echo "<tr><td>{$debt_history['cdebtref']}</td></tr>"; } echo "</table>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-230564 Share on other sites More sharing options...
neel_basu Posted April 16, 2007 Share Posted April 16, 2007 Honestly Speaking I've never used mysqli before. You Can Try this <?php //get debt history and display in table function get_debt_history() { $db=mysqli_connect('localhost','root','','debtnet'); if(mysqli_connect_errno()) { echo 'Could not connect to the database'; exit; } $query="SELECT * FROM history"; $result=mysqli_query($db,$query) or die(mysqli_error()); echo "<pre>"; if(!$debt_history = mysqli_fetch_array($result)) { exit('MySQL Error Occured'.mysql_error()); } while($debt_history=mysqli_fetch_array($result)){ echo $debt_history['cdebtref']."\n"; } echo "</pre>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-230572 Share on other sites More sharing options...
doucie Posted April 16, 2007 Author Share Posted April 16, 2007 You were right frost110 it was the query. Nice one. I just don't know why. I changed the query from "SELECT * FROM history" to "SELECT cdebtref, cnotes FROM history" and it works!! Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/47116-solved-help-with-error-message/#findComment-230574 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.