Re: mysql_num_rows

From: Date: Fri, 04 Apr 2003 23:33:24 +0000
Subject: Re: mysql_num_rows
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-142457@lists.php.net to get a copy of this message
Uh. no that can't be right becuase mysql_query() returns a pointer not an array. The variable does contain a string refering to the pointer ID but that's about all the information you're going to disseminate from print_r(); -- Kevin ----- Original Message ----- From: "Info@Best-IT" <info@best-it.biz> To: "Mike Tuller" <php@ce.anoka.k12.mn.us>; "J J" <squid_66@yahoo.com> Cc: "php mailing list list" <php-general@lists.php.net> Sent: Friday, April 04, 2003 4:18 PM Subject: Re: [PHP] mysql_num_rows > Someone helped me out with this to see exactly what the query is > returning... > > echo "<pre> the Query: "; print_r ($select_result); echo > "</pre>"; > > This should show you exactly what the result is getting... > > /T > > on 4/4/03 4:49 PM, Mike Tuller at php@ce.anoka.k12.mn.us wrote: > > > I can't believe I forgot that. time to go home for the week. > > > > thanks. > > > > On Friday, April 4, 2003, at 04:28 PM, J J wrote: > > > >> oh and your SQL statement is wrong: > >> > >> SELECT * FROM table WHERE ---- you are missing the > >> FROM... > >> > >> > >> > >> --- Mike Tuller <php@ce.anoka.k12.mn.us> wrote: > >>> I can't get mysql_num_rows to work for some reason. > >>> Here is a snippet > >>> of what I have > >>> > >>> > >>> $department_name = $_POST['department_name']; > >>> > >>> $select_query = "SELECT * WHERE department_name = > >>> '$department_name'"; > >>> $select_result = mysql_query($select_query, > >>> $db_connect); > >>> $select_total_rows = mysql_num_rows($select_result); > >>> > >>> if ($select_total_rows<1) > >>> { > >>> $insert_query = " insert into departments > >>> (department_name) > >>> values > >>> ('$department_name')"; > >>> > >>> mysql_query($insert_query, $db_connect) or die > >>> (mysql_error()); > >>> > >>> > >>> I am getting back an error mysql_num_rows(): > >>> supplied argument is not a > >>> valid MySQL result resource. I have looked over it > >>> again and again, and > >>> can't see what is wrong. Can anyone else see where > >>> the problem might be? > >>> > >>> Mike > >>> > >>> > >>> -- > >>> PHP General Mailing List (http://www.php.net/) > >>> To unsubscribe, visit: > >>> http://www.php.net/unsub.php > >>> > >> > >> > >> __________________________________________________ > >> Do you Yahoo!? > >> Yahoo! Tax Center - File online, calculators, forms, and more > >> http://tax.yahoo.com > >> > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#142457) next »