Jump to content

[RESOLVED] Using Xampp on localhost, connect to db with no password


flash gordon

Recommended Posts

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.
:)
This is what I use in my XAMPP install and it works fine:

$dbhost = 'localhost';
$dbuser = 'root';
$dbpasswd = '';
$dbname = 'test';

// Connect to DB
mysql_connect($dbhost,$dbuser,$dbpasswd);
mysql_select_db($dbname);
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.
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.
:)

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.