Jump to content

Help!! Cannot connect to mysql database


benjihubbs

Recommended Posts

i used this code to try and connect to my mysql database, but it hasn't worked

<html>
<head><title>Test MySQL</title></head>
<body>
<!-- mysql_up.php -->
<?php
$host=”localhost”;
$user=”root”;
$password=””;

mysql_connect($host,$user,$password);
$sql= "show status";
$result = mysql_query($sql);
if ($result == 0)
echo “<bError; “ . mysql_errno() . 
mysql_error() . “<b”;

?>
<!-- Table that displays the results -->
<table border=”1”>
<tr><td><b>Variable_name</b></td><td><b>Value</b>
</td></tr>
<?php
for ($i = 0; $i < mysql_num_rows($result); $i++) {
echo “<TR”;
$row_array = mysql_fetch_row($result);
for ($j = 0; $j < mysql_num_fields($result); 

$j++)
{echo “TD” . $row_array[$j] . “<td”;
}
echo “<tr”;
}
?>
</table>
<?php  ?>
</body></html>

 

 

But i end up with this error message:

 

 

Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host '”localhost”' (11004) in C:\xampp\htdocs\mysql_up.php on line 10

 

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\mysql_up.php on line 12

 

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\xampp\htdocs\mysql_up.php on line 12

 

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\mysql_up.php on line 23

 

 

Help please!!

Link to comment
https://forums.phpfreaks.com/topic/215456-help-cannot-connect-to-mysql-database/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.