script does not die

A

Anonymous

Guest
I've got a problem.


my code is not giving an error when it's supposed to.

Code:
$db = MYSQL_CONNECT($db_host,$db_user,$db_pass) or die("Could not connect: " . mysql_error());

echo 'Connection Complete';

it correctly errors out if the $db_user actually exists or if $db_pass has a value($db_user remaining null), if the user does not exist and a password is not set script does not die.

anyone?
 
Try this instead:

<?

$db = mysql_connect ("localhost", "username", "password");
$db_select = mysql_select_db ("table_name");
if (!$db){ echo "DB Connection Failure";}
if (!$db_select){ echo "DB Selection Failure";}

?>

Just fill in the blanks, I think you need to select a table within the database too, that may be why its not working...
 
it correctly errors out if the $db_user actually exists or if $db_pass has a value($db_user remaining null), if the user does not exist and a password is not set script does not die.

Hard coded or not this happens. It is due to a bug in mysql that results in a successful connection when the user does not exist. It can be considered by some a security hazard so by checking that information was actually input is a workaround.
 
Redcircle said:
it correctly errors out if the $db_user actually exists or if $db_pass has a value($db_user remaining null), if the user does not exist and a password is not set script does not die.

Hard coded or not this happens. It is due to a bug in mysql that results in a successful connection when the user does not exist. It can be considered by some a security hazard so by checking that information was actually input is a workaround.
you need to insert into youre code one string before any actios:
Code:
error_reporting (E_ALL ^ E_NOTICE);
 
this was happening with error reporting set to E_ALL in the php.ini

It's a bug somewhere I think.. i'm not too concrened with it.. Only reason I wondered about it is becasue the installation script that I wrote asks people that are installing the script to enter thier DB info.. I was getting a lot of questions on why the sctipt did't work.. mainly becasue people that didn't know what they were doing weren't putting in the db info.
 
wait a second, you mean what any user what regestering in youre DB have account in mysql->user database?
are you crazy man?
 
I had a simillar problem on 3.23.xx . As I remember right there was a small bug on mysql_error reporting function.
 
Back
Top