benjihubbs Posted October 8, 2010 Share Posted October 8, 2010 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!! Quote Link to comment https://forums.phpfreaks.com/topic/215456-help-cannot-connect-to-mysql-database/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 8, 2010 Share Posted October 8, 2010 Most of the quotes you are using in your code are curly/smart quotes and cannot be used in programming. You need to use simple straight quotes " or ' Quote Link to comment https://forums.phpfreaks.com/topic/215456-help-cannot-connect-to-mysql-database/#findComment-1120373 Share on other sites More sharing options...
benjihubbs Posted October 8, 2010 Author Share Posted October 8, 2010 Im sorry i don't understand what you mean im quite new to all this and am just reading through a book and this is what it was telling me to do Quote Link to comment https://forums.phpfreaks.com/topic/215456-help-cannot-connect-to-mysql-database/#findComment-1120378 Share on other sites More sharing options...
Pikachu2000 Posted October 8, 2010 Share Posted October 8, 2010 Look at these quotes (the ones you are using): ” ” versus these quotes (the ones you need to use): " " See the difference? Quote Link to comment https://forums.phpfreaks.com/topic/215456-help-cannot-connect-to-mysql-database/#findComment-1120379 Share on other sites More sharing options...
benjihubbs Posted October 8, 2010 Author Share Posted October 8, 2010 so how do i change them to the quotes i need to use? Quote Link to comment https://forums.phpfreaks.com/topic/215456-help-cannot-connect-to-mysql-database/#findComment-1120382 Share on other sites More sharing options...
Pikachu2000 Posted October 8, 2010 Share Posted October 8, 2010 I don't know how you change your keyboard mapping. You'll have to figure that out in your operating system. Quote Link to comment https://forums.phpfreaks.com/topic/215456-help-cannot-connect-to-mysql-database/#findComment-1120390 Share on other sites More sharing options...
benjihubbs Posted October 8, 2010 Author Share Posted October 8, 2010 I changed all of the quotes and now it works, thank you both very much for your help. I would never have thought it was something that stupid Quote Link to comment https://forums.phpfreaks.com/topic/215456-help-cannot-connect-to-mysql-database/#findComment-1120392 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.