Hi guys, I am having some trouble with a basic PHP while loop, everytime I launch my test_post.php file in my browser, I get a never ending loop, and I have no idea what I am missing!
Here is my PHP code:
<?php
mysql_connect('localhost', 'admin', '1234') or die(mysql_error());
mysql_select_db('json');
$test = mysql_query('SELECT user,pass FROM login WHERE user="john"');
$row = mysql_fetch_array($test, true);
while($row) {
echo "Username: ".$row['user']." Password: ".$row['pass']."<br />";
};
?>
I have three entries in my mySQL database that meet that criteria, but it keeps looping through the first one infinitely!
I am trying to get an array from the database and then convert it into a JSON object that can be passed back to populate a drop down list.
I also tried using PHP's count function to get the amount of entries in the array to limit the amount of times the while loop will execute, but even that results in a never ending loop.
My database structure consists of one table named login, which contains 3 columns, namely id, user and pass, within which I have 3 entries that have a 'user' value of 'john'.
Any ideas on what could be wrong?
PS: I couldn't apply code formatting to my post for some reason, the toolbar is gone!