RE: Re: Beginners Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Peter,

I'm also sort of a beginner.

That's along the lines that I was thinking.

Doesn't mysql_query return a result set object.  So in this sample, wouldn't the IF be testing if the result object was set?

I'm just trying to learn what's going on, I realized the code is wrong but didn't know why, which is why I didn't respond earlier.

Gary

> -----Original Message-----
> From: Peter Westergaard [mailto:p.j.westergaard@xxxxxxxxx]On Behalf Of
> Peter Westergaard
> Sent: Tue, January 08, 2008 11:09 AM
> To: php-db@xxxxxxxxxxxxx
> Subject:  Re: Beginners Problem
>
>
> Ben, I would say that the only reason
> > $select_sql_two = mysql_query($select_sql);
> >
> > if($select_sql_two) {
> >
>
> would refuse to execute is if $select_sql represents an invalid SQL
> statement.  Whether it has records or not, you should (if I'm
> not very
> much mistaken) get a resource returned in select_sql_two, which will
> make your IF succeed.
>
> You should probably check out http://php.net/mysql_query for more
> information on this function.  The difference between "empty
> result" and
> "invalid query" is significant.  Once you've determined that
> the query
> is valid, you must also then check to see if it returned any rows,
> possibly using a function like mysql_num_rows.
>
> Hope that helps!
> -P
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux