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

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
bmac11
Forum Newbie
Posts: 9
Joined: Thu Feb 17, 2005 3:14 pm

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

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it will only go inside it if there is an error during the query. Having no matches does not make an error.
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post 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.
Post Reply