I can't connect to a database:
My config = Windows, PHP Version 4.3.2, MySQL 3.23.54-nt
This works...
<?php
$user = "";
$pwd = "";
$db = "php24";
$link = mysql_connect();
if (! $link)
die ("Could not connect to MySQL");
print "Successfully connected to server<p>"
?>
This does not...
<?php
$user = "";
$pwd = "";
$db = "php24";
$link = mysql_connect();
if (! $link)
die ("Could not connect to MySQL");
print "Successfully connected to server<p>"
mysql_select_db($db)
or die ("Could not select $db: ".mysql_error() );
print "Successfully selected database \"$db\"<p>";
mysql_close($link);
?>
I have tried multipul databases and even tried creating a new one (php24)
Any suggestions?
Thanks
I can't connect to a database:
Moderator: General Moderators
-
greenAlien
- Forum Newbie
- Posts: 8
- Joined: Sun Aug 17, 2003 10:08 pm
Code: Select all
mysql_connect("HOSTNAME",$user, $pwd);-
greenAlien
- Forum Newbie
- Posts: 8
- Joined: Sun Aug 17, 2003 10:08 pm
-
greenAlien
- Forum Newbie
- Posts: 8
- Joined: Sun Aug 17, 2003 10:08 pm
- trollll
- Forum Contributor
- Posts: 181
- Joined: Tue Jun 10, 2003 11:56 pm
- Location: Round Rock, TX
- Contact:
Just as a quick note: lots and lots of people post things without giving any info. Things like pasting three pages of code and just saying,"Why doesn't this work?" to give you an extreme example. Though I don't like sarcasm towards people who probably feel quite annoyed by a problem to begin with, bong did try to help.
Anyway, did adding the ";" to allow it to print anything out?
Anyway, did adding the ";" to
Code: Select all
print "Successfully connected to server<p>"