Jump to content

I dont get a conection or a error message


umekille78

Recommended Posts

Hi all!I dont get a conection or a error message when I try to conect to MySQL with PHP like this:

print("1");$dbHandler=@mysql_connect("localhost","name","pass")or die("2");print("3");$DataBas=mysql_select_db("TestDB");$q="SELECT * FROM Anvandare";$a=mysql_query($q);print($a);print("4");

I added printouts of numbers to see what hapend. I only got "1". Nothing more. I have created a user in the data base TestDB with name and password. I use PHP 5 on Apache and I have installed MySQL on the same computer.What am I doing wrong. This is how my book said that I should wright the code.HELP please :) /Per

Link to comment
Share on other sites

Dan> Why not? It does actually, I just tested.umekille78> You might also addini_set('display_errors', 1);error_reporting(E_ALL);at the begninning of your script, if it still doesn't show any warning.

Link to comment
Share on other sites

The @ sign actually ignores any error or warning message, that caused it. And you didn't get the 2 note also because die() must get a string to print it, not a digit, even if it is quoted. :)

Quoted digitals are strings...anything that is quoted is a string...period!
Link to comment
Share on other sites

Haha, not really :)For what I tried, I may be wrong, but I tried to die a string that was a number, and it didn't show it. As for Die may be passed two types of arguments, a string or a certain error message (a number)

Link to comment
Share on other sites

I meant, even then, it did not printed the number :)So it was not the actual string it should have recognised, but the number for the error that occurred :/I don't get it either, but the quotes have their mmeaning anywhere else, but here :)

Link to comment
Share on other sites

You guys know there's an answer to all of this, right?http://us2.php.net/manual/en/function.die.php :

die -- Equivalent to exit()
http://us2.php.net/manual/en/function.exit.php :
exit -- Output a message and terminate the current scriptDescriptionvoid exit ( [string status] )void exit ( int status )Note: This is not a real function, but a language construct. Note: PHP >= 4.2.0 does NOT print the status if it is an integer. The exit() function terminates execution of the script. It prints status just before exiting. If status is an integer, that value will also be used as the exit status. Exit statuses should be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used. The status 0 is used to terminate the program successfully.
It appears that the only thing that is undocumented is that a numeric string gets treated as an integer.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...