Page 1 of 1

Simple question----- if (!$result) {

Posted: Mon Feb 28, 2005 8:53 pm
by bmac11
I found this method in the php.net manual and it wont go into the if statement if there is an Invalid Query. Regardless of what is entered, it skips it.

Code: Select all

$result = mysql_query("SELECT * FROM links WHERE nick = '$name_entered' ");
	if (!$result) {
		die ("Error, No match in db. " . mysql_error());
         } // end if

http://us4.php.net/manual/en/function.mysql-query.php

Posted: Mon Feb 28, 2005 9:18 pm
by feyd
it will only go inside it if there is an error during the query. Having no matches does not make an error.

Posted: Tue Mar 01, 2005 5:21 am
by CoderGoblin
You may want to look up
For selection http://www.php.net/manual/en/function.m ... m-rows.php

For deletion/updates etc
http://www.php.net/manual/en/function.m ... d-rows.php

These are useful to track what is happening to things.