Page 1 of 1

Urgent help with mysql data not displaying using PHP, please

Posted: Mon Feb 22, 2010 10:50 pm
by khkit
Hey guys, so I have a database called b9_3095165_mmdb with a table called Persons
and it has two entries for FirstName and LastName



I am simply trying to output this to the web browser using this PHP code and all I get is a blank page but no mysql records shown.


Here is the codel

Code: Select all

 
<?php
$username = "b9_3095165";
$password = "REMOVED";
$hostname = "REMOVED";  
$dbh = mysql_connect($hostname, $username, $password) 
    or die("Unable to connect to MySQL");
$selected = mysql_select_db("b9_3095165_mmdb",$dbh) 
    or die("Could not select first_test");
$result = mysql_query("SELECT FirstName, LastName FROM Persons");
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
print " Name:".$row{'FirstName'}." ;
}
mysql_close($dbh);
?> 
 
Can someone tell me what It is not displyaing the data in the mysql table.

Re: Urgent help with mysql data not displaying using PHP, please

Posted: Mon Feb 22, 2010 10:54 pm
by Benjamin
I removed your hostname and password.

This line:

Code: Select all

print " Name:".$row{'FirstName'}." ;
Should be:

Code: Select all

echo " Name: {$row['FirstName']}";

Re: Urgent help with mysql data not displaying using PHP, please

Posted: Mon Feb 22, 2010 11:29 pm
by pbs
Line

Code: Select all

 
print " Name:".$row['FirstName'] ;
 

Re: Urgent help with mysql data not displaying using PHP, please

Posted: Mon Feb 22, 2010 11:30 pm
by khkit
Works amazingly!!!!!!!!!!!!!



Thanks bro



Omar