[thelist] something wrong with my SQL query

Rich Gray rich at f1central.net
Wed Nov 20 12:02:01 CST 2002


Tom

IIRC $result will still be true if the select returns no rows. It'll only be
false if the query is malformed.
You need to check (mysql_num_rows($result) > 0)

HTH
RIch
-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Tom Dell'Aringa
Sent: 20 November 2002 17:10
To: thelist at lists.evolt.org
Subject: [thelist] something wrong with my SQL query


Hi all, I am trying to disallow a deletion of a category if a
category exists already in a table. Here is my code:

//first check and see if the category is being used. If it is,
disallow deletion

$result = @mysql_query("SELECT item FROM menuitem WHERE categoryID =
$id");
if($result)
{
	$message = "Oops! You cannot delete that category, it is being used!
If you really wish to delete this category, you must first remove it
from any menu item that refers to it. - ";

	header("Location: manage_cat.php?message=".$message);
}

I added a test category that is NOT in the menuitem table. Yet it
always tells me I can't delete it because it exists. I'm guessing
this has something to do with the way I set it up (if($result)??)

When I print out the $result I get "RESOURCE id" instead of the sql
so I'm wondering if my logic is wrong..

TIA

Tom

=====
var me = tom.pixelmech.webDeveloper();

http://www.pixelmech.com/
http://www.maccaws.com/
[Making A Commercial Case for Adopting Web Standards]

__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - Let the expert host your site
http://webhosting.yahoo.com
--
* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

For unsubscribe and other options, including the Tip Harvester
and archives of thelist go to: http://lists.evolt.org
Workers of the Web, evolt !





More information about the thelist mailing list