Hi,
I am having a problem connecting to a MySQL database via PHP.

I have Apache 2.0.52, PHP 5.0.2 and MySQL 4.1 installed and working OK 
individually.
I have copied phpmysql.dll and mysqli.dll at different times to 
Windows/System32.
I have set up a successful MyODBC connection with the database - so it exists.
I can access MySQL from the command prompt, and from a web interface with no 
problem.
However, when I run the following code I get a "Unable to connect to the 
database server at this time." error message.
If some kind soul could point me in the right direction I would be very 
grateful!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This is the code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>

<head>
<title>Our List of Jokes</title>
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
</head>

<body>
 <?php
 // Connect to the database server
 $dbcnx = @mysql_connect('localhost', 'root', 'thisismypassword');
 if (!$dbcnx) {
 exit('<p>Unable to connect to the ' .
 'database server at this time.</p>');
 }
 // Select the jokes database
 if ([EMAIL PROTECTED]('ijdb')) {
 exit('<p>Unable to locate the joke ' .
 'database at this time.</p>');
 }
 ?>
<p>Here are all the jokes in our database:</p>
<blockquote>
 <?php
 // Request the text of all the jokes
 $result = @mysql_query('SELECT joketext FROM joke');
 if (!$result) {
 exit('<p>Error performing query: ' . mysql_error() . '</p>');
 }
 // Display the text of each joke in a paragraph
 while ($row = mysql_fetch_array($result)) {
 echo '<p>' . $row['joketext'] . '</p>';
 }
 ?>
</blockquote>
</body>
</html>

Reply via email to