Re: function not returning query

From: Date: Tue, 24 Nov 2009 01:08:37 +0000
Subject: Re: function not returning query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-300041@lists.php.net to get a copy of this message
Likely your query failed due to an error. Try adding an or die(mysql_error()) to the end of your mysql_query statement to see what that error maybe Bastien Sent from my iPod On Nov 23, 2009, at 7:22 PM, Allen McCabe <allenmccabe@gmail.com> wrote:
Hi, thanks for reading, I hope you can help: In my main file for an orders page I have the following code: if (isset($_GET['filterby'])) { $resultOrders = adminFilterQuery(); $numberOfOrders = mysql_num_rows($resultOrders); } else { $resultOrders = mysql_query("SELECT * FROM afy_order;") or die(mysql_error("Could not query the database!")); $numberOfOrders = mysql_num_rows($resultOrders); } adminFilterQuery() is a custom function that is supposed to return a mysql_query, here are the last few lines of this function: $query = "SELECT * FROM afy_order WHERE school_id = '{$school}' ORDER BY {$order_by_param};"; $result = mysql_query($query); return $result; l am getting this error when I try to filter my query using a form in tandem with the quey building function: *Warning*: mysql_num_rows(): supplied argument is not a valid MySQL result resource where the line is the one where I use the mysql_num_rows function. What am I missing here? Thanks!


« previous php.general (#300041) next »