PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hello,
I'm a bit of a newbie to PHP and just can't understand why the following code isn't working. Please could someone advise me on what is going wrong....
The script is...
<?
$username="digslis_root";
$password="*****";
$database="dislis_addresses";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM contacts";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo "<b><center>Database Output</center></b><br><br>";
$i=0;
while ($i < $num) {
$forename=mysql_result($result,$i,"forename");
$surname=mysql_result($result,$i,"surname");
echo "<b>$first $last</b><br>";
$i++;
}
?>
Obviously I have changed the ***** for my password. However when I run the script all I get is the following message:
Warning: mysql_connect(): Access denied for user: 'digslis_root@localhost' (Using password: YES) in /home/digslis/public_html/test3.php on line 6
Unable to select database
I have a feeling that this isn't a script problem but more a problem with my account.
Connected!
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/digslis/public_html/test3.php on line 11
Database Output
So obviously I'm getting somewhere but don't understand why I'm now getting this message. Any ideas?