tags:

views:

31

answers:

2
<?php
$dbhost = 'xxxx';
$dbuser = 'xxxx';
$dbpass = 'xxxx';
$dbname = 'xxxx';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

mysql_select_db($dbname);
$result = mysql_query("SELECT * FROM mytable");

$row = mysql_fetch_array($result)
?>
<?php foreach ($rows as $row): ?>
  <tr align="center">
          <td><?php echo htmlspecialchars($row['Picturedata']); ?></td>
          </tr>
<?php endforeach; ?>

I get an error: Warning: Invalid argument supplied for foreach()

A: 

it should be $rows and not $row

$rows = mysql_fetch_array($result)
easement
Thanks,The error is not showing agian, but still not fetching any data:(
Joe
A: 

You need to do a while loop to pull each rowset. *mysql_fetch_array()* will only pull one row at a time. Consider this solution:

<?php
$dbhost = 'xxxx';
$dbuser = 'xxxx';
$dbpass = 'xxxx';
$dbname = 'xxxx';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

mysql_select_db($dbname, $conn);
$result = mysql_query("SELECT * FROM mytable", $conn);

while ($row = mysql_fetch_array($result)) {
    echo '<tr align="center"><td>' . htmlspecialchars($row['Picturedata']) . '</td></tr>';
}
?>
Mark
That worked !Thans
Joe