Select ignoring first entry


I am new to php and Mysqli, I’ve written what I think is a basic script, but the Select command seems to be ignoring the first entry from my DB when I execute it. I’ve tried changing the * to a more precise string and it ignores the first from this list too.

Any ideas?


include $_SERVER[‘DOCUMENT_ROOT’] . ‘\360feedback\includes\’;

include $_SERVER[‘DOCUMENT_ROOT’] . ‘\360feedback\includes\’;

include $_SERVER[‘DOCUMENT_ROOT’] . ‘\360feedback\includes\magicquotes.php’;

$result = mysqli_query($link, ‘SELECT * FROM user’);

$row = mysqli_fetch_array($result);

while ($row = mysqli_fetch_array($result))
$user = $row[‘user_name’];

<p>Here are all the users in the database: </p>
<?php foreach($user as $users): ?>
<?php echo htmlspecialchars ($users, ENT_QUOTES, ‘UTF-8’);?>
<?php endforeach; ?>[/COLOR]

// the following line fetches the FIRST user, but
// DOES NOTHING with it
$row = mysqli_fetch_array($result);

// The next statement fetches all the other users
// But of course not the first one, that was already fetched
while ($row = mysqli_fetch_array($result))
$user[] = $row['user_name'];

so you need to remove the line

$row = mysqli_fetch_array($result);

That’s all well and good and works fine, however I need to call all the users, or a selection of them into a web page and therefore I can’t use command line.

hint: run the SELECT statement outside of php (e.g. in the mysql command line, or in phpmyadmin or sqlyog or heidisql or …) and you will see the first row appear as if by magic


That sorted it.

This thread can be closed