Creating MySQL connection

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
maggelo
Forum Newbie
Posts: 1
Joined: Tue Mar 01, 2005 5:47 am
Location: the netherlands

Creating MySQL connection

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 :)
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post 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
Post Reply