Hello,
I am very new to php and trying to work stuff around as they come across.
I am trying to display the output of a query on the web page. Following is the code.
<?php
$username="xxxxxxxxx";
$password="xxxxxxxxx";
$database="xxxxxxxxx";
mysql_connect('localhost',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM user";
$result = mysql_query ($query) or die(mysql_error());
$num=mysql_numrows($result) or die(mysql_error());
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
while ($i < $num) {
$zip=mysql_result($result,$i,"zipcode");
$area=mysql_result($result,$i,"area");
$city=mysql_result($result,$i,"city");
echo "<b>Zip: $zip</b><br>Area: $area<br>City: $city<br><hr><br>";
$i++;
}
?>
The code runs file on the terminal window. However, when I try to execute the file from a browser ,I get the following error message:
Notice: Use of undefined constant localhost - assumed 'localhost' in /users/home/xxxx/web/public/query.php on line 6 SELECT command denied to user 'xxxxxx'@'localhost' for table 'city'
Why does it say select command denied ??