Vassilis
Vassilis

Reputation: 341

Retrieve data from MySQL with php

I'm trying to retrieve some data from a MySQL database but when I execute the php page it shows a white page. Any idea if and what I do wrong...

$query = mysql_query("SELECT * FROM EMPLOYEES");
while ($row = mysql_fetch_array($query));
{
 $Ssn=$row['Ssn'];
 $UnionMembershipNumber=$row["UnionMembershipNumber"];
 $fname=$row['Fname'];
 $surname=$row['Surname'];
 $StreetName=$row['StreetName'];
 $StreetNumber=$row['StreetNumber'];
 $PostalCode=$row['PostalCode'];
 $Salary=$row['Salary'];
 echo $fname."".$surname."".$StreetName."".$StreetNumber."".$PostalCode."".$Salary."<br>";
}
?>

Upvotes: 0

Views: 239

Answers (4)

bensiu
bensiu

Reputation: 25564

while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) { // no semicolon

would not hurt, try print_r ($query); before while loop to make sure that you got results, and make sure that your mysql_connect() and mysql_select_db() did not fail.

Upvotes: 1

Hilydrow
Hilydrow

Reputation: 918

Yes. Remove the ; at the end of the while

$query = mysql_query("SELECT * FROM EMPLOYEES");
while ($row = mysql_fetch_array($query))
{
...

Upvotes: 6

Alec
Alec

Reputation: 9078

while ($row = mysql_fetch_array($query));
{

Remove the ;.

Also, try adding error_reporting(E_ALL); at the beginning of the code for debugging.

Upvotes: 2

AnthonyHurst
AnthonyHurst

Reputation: 133

you made the mysql_connect(); and mysql_select_db(); correct?

Upvotes: 2

Related Questions