Quote:
Originally Posted by comports
OK All,
Starting off with MySql and have a really stupid question. I have a DB set up but can't seem to even get the connection right...
I have a page that I want to connect to the DB and just say ok but it does not work.. I ave an incling that it's the "localhost" bit but could be wrong..!!
Code:
<?php
$link=mysql_connect("localhost", "ash", "password");
if(mysql_select_db("mysql", $link)) echo "connected to DB";
Else die ("Connection failed");
?>
Could someone let me into the secret of connecting to my DB.
Thanks
Ash
|
I'm no expert, but I would suggest something like:
PHP Code:
<?php
$link=mysql_connect("localhost", "ash", "password");
if(mysql_select_db("mysql", $link)) {
echo "Connected to DB"; } else { die ("Can't connect to DB.");
}
?>
__________________
Regards,
Josh Hold
eUKhost Blog: Over 1000 Computer Related Articles to Sink Your Teeth Into!
LDN GIGS - Gig Listings for London
Super Moderator
I'm only a forum gremlin (moderator), and do not work for eUKhost in any way. Opinions expressed by me are mine only, and do not reflect those of either eUKhost or any company that may be listed above.
I don't bite, honest.