Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

what does @ mean 1

Status
Not open for further replies.

parthshukla

Programmer
May 27, 2003
5
AU
hi guys, i am doing some examples from a book, and i can't work out when they say this

@ $db = mysql_connect('localhost','root','');
mysql_select_db('users');
@ $query = "select from login where user=$user and pass=password('$pass');

the first thing i don't get is what does the sign @ do...

the other thing i don't get is why haven't they put something like this in the second line..
mysql_select_db('users', $db)

i meant why haven't they included the connection to $db


and lastly what does this do, pass=password('$pass')

thanks
 
The @ sign is used to suppress error reporting if the directive following it fails.

There are three ways to control errors, listed in the way I think it should be handled:

1. Take care of the error in your code. Check for failiure of a command and handle it with an error handling routine.
2. Suppress the error message with the @ sign.
3. Set the level of error reporting so less/no errors are displayed.

#1 really is the choice because 2 and 3 just introduce you to a kind of blindness and oblivion what's going on in your code.

Your second question:
The resource_link parameter in mysql_select_db is optional. It takes the default connection which works fine as long as you don't have another connection open. When you want to access more than one server simultaneously the resource_link parameter retrieved from the mysql_connect() or mysql_pconnect() is required to identify the resource to be accessed.

Third:
It looks like a fragment from a SQL statement, right?
MySQL uses the PASSWORD() function to encrypt a string into a non-decryptable password. The encrypted passwords are stored in the database and submitted passwords are first encrypted and then compared. This makes sure that even when you can find the encrypted password string that you can't discover the plain-text password.
When you login at the command line into MySQL and supply a password it is automatically passed through PASSWORD() and then compared to the mysql.users table stored password string.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top