I have similar code in a page of mine. The other thing you might want to try is hard coding in a user name and password and then if it work, maybe it is your $_POST. Also, try using ' instead of ". I have found that to cause some problems, although it shouldn't. Here is some code I had.
$user = "user"
$pass = "pass"
$server = "server"
//$user = $_POST["username"]
//$pass = $_POST["pwd"]
$link = mysql_connect($server, $user, $pass);
if (!$link) {
die('Could not connect: ' . mysql_error());
}else{
//Do stuff
}
Main Topics
Browse All Topics





by: winglis4Posted on 2004-06-22 at 06:06:43ID: 11368637
Why is this connect statement inside an if statement? $_POST["username"], $_POST["pwd"])) {
Assuming that the connect being inside an if statement is OK, you are using the wrong operator there.
By using a single = you are assigning $phpLink the value of
mysql_connect("localhost",
......
}
You should use a double == which is a comparsion operator, but I still don't think this connect should be inside an 'if' statement at all. I don't think it will work for you that way...