how to connect to the mysql database

Problems with the Mac OS X version of XAMPP, questions, comments, and anything related.

how to connect to the mysql database

Postby mpaev » 07. March 2007 21:05

im trying a simple database tutorial, and i can't make contact to the database, I get this warning:

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2) in /Applications/xampp/xamppfiles/htdocs/test/- on line 22 Could not connect to database

my database.php is in /Applications/xampp/xamppfiles/htdocs/test/

and the php script connecting to the database is:

// Connect to MySQL
if ( !( $database = mysql_connect( "localhost",
"httpd", "" ) ) )
die( "Could not connect to database" );

// open Products database
if ( !mysql_select_db( "Products", $database ) )
die( "Could not open Products database" );


what am I doing wrong :S
mpaev
 
Posts: 7
Joined: 05. March 2007 12:10

Postby Wiedmann » 07. March 2007 21:21

You have an user "httpd" (with no password) in MySQL?
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby mpaev » 07. March 2007 21:33

ehm, im sorry im a bit of a noob on database.

I not sure what your refering to.? :S
mpaev
 
Posts: 7
Joined: 05. March 2007 12:10

Postby Wiedmann » 07. March 2007 22:20

I not sure what your refering to.? :S

Well:
Code: Select all
if ( !( $database = mysql_connect( "localhost", "httpd", "" ) ) )

In this function you want connect to a MySQL server at "localhost" with the user "httpd" and no password "".
--> So I ask you. You have this user in MySQL?

ehm, im sorry im a bit of a noob on database.

And of course PHP...

im trying a simple database tutorial,

BTW: It's allways a good idea to read the PHP (MySQL) manual and trying out the examples there.
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany


Return to XAMPP for Mac OS X

Who is online

Users browsing this forum: No registered users and 6 guests