I have the following PHP code:
$con = mysql_connect("localhost","name","pass") or die(mysql_error());
$db = "db";
mysql_select_db($db,$con);
Now in my experience, $con should be true or false. When I echo $con I get:
Resource id #25
If I do the following code, the echo never fires (as to be expected after the above statement):
if($con) { echo "it worked"; }
When I run a query against this connection, everything works as expected. Is there a reason why this $con will not be true or false?
What am I doing wrong?
Thanks
Returns a MySQL link identifier on success or FALSE on failure.. Also, judging by the big red warning box on mysql_connect's docs you should probably use mysqli or pdo.