flash gordon Posted November 30, 2006 Share Posted November 30, 2006 Hi There,I have [url=http://www.apachefriends.org/en/xampp.html]xampp[/url] install for windows. By default, there is no password set for the databases. The user name is "root". What is the correct mysql_connect() command to get it to connect to the db? I have tried[code=php:0]$database = "foo";$table = "calendar";$username = "root";$password = "";mysql_connect("localhost", $username, $password) or die ("Could not connect to database");[/code]but it wont connect. Thanks.:) Quote Link to comment https://forums.phpfreaks.com/topic/29001-resolved-using-xampp-on-localhost-connect-to-db-with-no-password/ Share on other sites More sharing options...
Psycho Posted November 30, 2006 Share Posted November 30, 2006 This is what I use in my XAMPP install and it works fine:$dbhost = 'localhost';$dbuser = 'root';$dbpasswd = '';$dbname = 'test';// Connect to DBmysql_connect($dbhost,$dbuser,$dbpasswd);mysql_select_db($dbname); Quote Link to comment https://forums.phpfreaks.com/topic/29001-resolved-using-xampp-on-localhost-connect-to-db-with-no-password/#findComment-132861 Share on other sites More sharing options...
wildteen88 Posted November 30, 2006 Share Posted November 30, 2006 That code is completly fine flash gordon.What error(s) do you get? POst them here in full if you get any. ALso add the mysql_error() function to the die clause. So this line:[code=php:0]mysql_connect("localhost", $username, $password) or die ("Could not connect to database");[/code]is like this:[code=php:0]mysql_connect("localhost", $username, $password) or die ("Could not connect to database<br /><br />" . mysql_error());[/code]This should now retrieve an error message from MySQL if there is an error occurring anywhere. Quote Link to comment https://forums.phpfreaks.com/topic/29001-resolved-using-xampp-on-localhost-connect-to-db-with-no-password/#findComment-132863 Share on other sites More sharing options...
flash gordon Posted November 30, 2006 Author Share Posted November 30, 2006 Thanks guys! :)Yea...suddenly it is working today. I put it down for a week and came back. My error message was "Could not connect to database". My only guess is that I didn't have the mySQL running. I really have no idea, but it is all fine now. Thanks again guys! I wish I could repay the php favor, but I'm not that great. If you ever need any ActionScript help, come on over to http://actionscript.org/forums and look me up. Cheers.:) Quote Link to comment https://forums.phpfreaks.com/topic/29001-resolved-using-xampp-on-localhost-connect-to-db-with-no-password/#findComment-132892 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.