mysql_num_rows & '@'

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

mysql_num_rows & '@'

Post by nigma »

Can anyone tell me what the difference between refering to calling a function but placing a @ symbol before it and calling it normally without @ symbol?

Example #1:

Code: Select all

$rowsReturned = @mysql_num_rows($result);
Example #2:

Code: Select all

$rowsReturned = mysql_num_rows($result);
Thanks for any help provided.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

The @ is used to suppress errors. mysql_num_rows() always returns true unless the result you're pointing at hasn't returned correctly - e.g. the query has failed. If you expect that to happen, you should probably terminate output before you call mysql_num_rows(): e.g.

Code: Select all

if(!($check_Subjectquery = mysql_db_query($db2,$checkSubject)))
{
 echo "Query failed: " . mysql_error();
 exit;
}
Mark
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Although don't use mysql_db_query() 'cause it be deprecated.

Mac
Post Reply