Hey,
I just bought the sitepoint book about PHP & MySQL by Kevin Yank And trying to set up a page that will connect to a mysql database and select data from a table.
Here's some background info:
I have MySQL and PHP running on Win2000 server (192.168.1.1) and telnet service running. I am able to connect to mysql via telnet from another machine on my network (btw, none of this is accessible through the firewall) I am not able to connect to mysql via a php string.
I followed the steps in Ch. 4 verbatim, but I am getting this error:
I put an echo in there to get what $dbcon was after it failed.Unable to connect to the database server at this time.
Access denied for user: 'root@MYCOMPUTERHOST.com' (Using password: YES)
I used this line:
(I put my real password in between the parenthesis) Any ideas why it won't connect? When telnetting to the server and executing [mysqladmin.exe -u root reload] it errors and says the same error only listing 'No' instead of 'Yes'. When I -p for password and enter the right password I the command executes fine. So I know the password is functional.PHP Code:$dbcon = mysql_connect("192.168.1.1", "root", "[mypasswd]");
What's up with my code? Oh, here is the actual code in the page if that helps:
Any ideas? Also, why does the book put things like this in:PHP Code:<html>
<title>View Blackbook</title>
<body>
<?php
//Connect to database
$dbcon = @mysql_connect("192.168.1.1" , "root" , "**mypass**");
if (!$dbcon) {
echo( "<p>Unable to connect to the database server at this time.</p>" . mysql_error() );
exit();
}
echo("$dbcon");
// Select the blackbook database
if (!@mysql_select_db("blackbook", $dbcon) ) {
echo( "<p>Unable to locate the Blackbook " . "database at this time.</p>" );
exit();
}
?>
<p> here is your listing</p>
<blockquote>
<?php
// Request the text of members table
$result=@mysql_query("select firstname, lastname, email, username, street1, city, state, zip, hphone from members");
if (!$result) {
echo("<p>Error performing query: " . mysql_error() . "</p>");
exit();
}
// Display the address listings
while ( $row = mysql_fetch_array($result) ) {
echo("<p>" . $row["firstname, lastname, email, username"] . "</p>");
}
?>
</blockquote>
</body>
</html>
Why does it break in the middle of the sentence to '.' and then pick up again? I can see why if you were inserting a string in the echo, but this isn't the case here, is it?PHP Code:echo( "<p>Unable to locate the Blackbook " . "database at this time.</p>" );







Bookmarks