Urgent help with mysql data not displaying using PHP, please

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
khkit
Forum Newbie
Posts: 4
Joined: Fri Feb 19, 2010 4:46 pm

Urgent help with mysql data not displaying using PHP, please

Post 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.
Last edited by Benjamin on Mon Feb 22, 2010 10:52 pm, edited 1 time in total.
Reason: Added [code=php] tags.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

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

Post 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']}";
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

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

Post by pbs »

Line

Code: Select all

 
print " Name:".$row['FirstName'] ;
 
khkit
Forum Newbie
Posts: 4
Joined: Fri Feb 19, 2010 4:46 pm

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

Post by khkit »

Works amazingly!!!!!!!!!!!!!



Thanks bro



Omar
Post Reply