Page 1 of 1

Creating MySQL connection

Posted: Tue Mar 01, 2005 5:51 am
by maggelo
hey everybody!

im not that experienced with PHP but i got a question:
what's wrong with the following lines of php code? i just can't get it to work :(

mysql_connect(localhost,root,inktvis);
@mysql_select_db(testdatabase) or die( "Unable to select database");
mysql_close();

thanks, michael

Posted: Tue Mar 01, 2005 6:03 am
by Chris Corbyn
Why doesn't it work? You getting errors?

Put quotes around your username and password.... btw, best the **** out passwords in forums :)

Posted: Tue Mar 01, 2005 6:05 am
by smpdawg
First. Please use the code tags to post examples.

Two. You need to put the values inside of quotes. For example:

Code: Select all

mysql_connect('localhost','root','inktvis');
@mysql_select_db('testdatabase') or die( "Unable to select database");
mysql_close();
This link has some useful information. http://www.php.net/manual/en/language.variables.php