0

Please am trying to display individual reocords of a mysql database using php, along the line i got the error *mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\NASU\fetchall.php on line 28*

My code is as follows...

<?php

$conn = mysql_connect("localhost","root","");


mysql_select_db("tblr", $conn);


$rs = mysql_query("SELECT * FROM tblr");


while ($row = mysql_fetch_array($rs)) {

?>

<center>

<div class="m">

<form name="register" method="post" action="">
<fieldset><legend>Report</legend>

<div class="a"><div class="l">Name</div><div class="r"><?php echo $row['name1'] ?></div></div>

<div class="a"><div class="l">ID No.</div><div class="r"><?php echo $row['id'] ?></div></div>

<div class="a"><div class="l">Bank</div><div class="r"><?php echo $row['bank'] ?></div></div>

<div class="a"><div class="l">Account Number</div><div class="r"><?php echo $row['accno'] ?></div></div>

<div class="a"><div class="l">Opening Balance</div><div class="r"><?php echo $row['ob'] ?></div></div>

<div class="head1">Month</div>
<div class="head2">savings</div>
<div class="head3">Withdrawal</div>

<div class="a"><div class="l">January</div><div class="r"><?php echo $row['january'] ?><?php echo $row['januaryw'] ?></div></div>

<div class="a"><div class="l">February</div><div class="r"><?php echo $row['february'] ?><?php echo $row['februaryw'] ?></div></div>

<div class="a"><div class="l">March</div><div class="r"><?php echo $row['march'] ?><?php echo $row['marchw'] ?></div></div>

<div class="a"><div class="l">April</div><div class="r"><?php echo $row['april'] ?><?php echo $row['april'] ?></div></div>

<div class="a"><div class="l">May</div><div class="r"><?php echo $row['may'] ?><?php echo $row['mayw'] ?></div></div>

<div class="a"><div class="l">June</div><div class="r"><?php echo $row['june'] ?><?php echo $row['junew'] ?></div></div>

<div class="a"><div class="l">July</div><div class="r"><?php echo $row['july'] ?><?php echo $row['julyw'] ?></div></div>

<div class="a"><div class="l">August</div><div class="r"><?php echo $row['august'] ?><?php echo $row['augustw'] ?></div></div>

<div class="a"><div class="l">September</div><div class="r"><?php echo $row['september'] ?><?php echo $row['septemberw'] ?></div></div>

<div class="a"><div class="l">October</div><div class="r"><?php echo $row['october'] ?><?php echo $row['octoberw'] ?></div></div>

<div class="a"><div class="l">November</div><div class="r"><?php echo $row['november'] ?><?php echo $row['novemberw'] ?></div></div>

<div class="a"><div class="l">December</div><div class="r"><?php echo $row['december'] ?><?php echo $row['december'] ?></div></div>

<div class="a"><div class="l">Total</div><div class="r"><?php echo $row['totald'] ?><?php echo $row['totalw'] ?></div></div>

<div class="a"><div class="l">Current Balance</div><div class="r"><?php echo $row['cb'] ?></div></div>

<div class="a"></div>

</fieldset>

</form>

</div>

</center>

<?php
}
?>

 </BODY>
</HTML>

Any help would be greatly appreciated because am kind of not even sure what av done.

Crossyde
  • 5
  • 1
  • 4
  • 1
    `select * from table_name`. but you have given database name in query – Kumar V Jan 09 '14 at 14:03
  • It would be a good idea to stop using `mysql_*` functions now. No use learning with them, as they are deprecated, unsafe, and you will have to relearn everything in the future. Please look at the PHP `PDO` object or `mysqli_*` functions. Also, use prepared statements instead of raw queries, or you potentially leave yourself open to SQL injection. – crush Jan 09 '14 at 14:08
  • Thanks a bunch Kumar_v... I just figured i was using the wrong database name so after using the correct database name my code runds perfectly well... one more thing though.... the page is not seeing my style sheet. Do you think you can help with that? – Crossyde Jan 09 '14 at 14:10
  • Thanks Crush... Am glad I met you.... will keep that in mind – Crossyde Jan 09 '14 at 14:14
  • possible duplicate of [mysql\_fetch\_array() expects parameter 1 to be resource, boolean given in select](http://stackoverflow.com/questions/2973202/mysql-fetch-array-expects-parameter-1-to-be-resource-boolean-given-in-select) – John Conde Jan 10 '14 at 01:41

0 Answers0