No data being displayed on the page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

No data being displayed on the page

Post by Jim_Bo »

Hi,

With the following code .. nothing is being displayed to the browser .. not even the plain text:

Code: Select all

<?php

require '../db.php';

$sql = "SELECT * FROM table WHERE id ='1'";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$id = $row['id']; 
$name = $row['name']; 

?>


<table width="51%" border="0" align="center" cellpadding="4" cellspacing="4">
  <tr>
    <td>

<?php
if ($_SESSION['user_level'] == 5) {
?>


<div align="center"><a href="../index.php?pages=page&id=<?php echo $row['id']; ?>">EDIT</a><br>

<?php

} else {

}

?>
      	
	  </div>
    </td>
  </tr>
  <tr>
    <td>
      <div align="center"><?php echo $row['name']; ?> Bla</div>
    </td>
  </tr>
</table>

<?php
}
?>
Stumped ..

Thanks
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

change

Code: Select all

$result = mysql_query($sql);
to

Code: Select all

$result = mysql_query($sql) or die(mysql_error());
See what happens!
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

Still blank page .. I know the query it correct .. still at the least "bla" should be showing on the screen.

thanks
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Jim_Bo wrote:still at the least "bla" should be showing on the screen.
not if the script never enters the while loop!

Make sure your query is returning some results!
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post by Jim_Bo »

Hi,

Doh table has been flushed .. no records :oops:

Cheers
Post Reply