Re: Best way to figure out whether a query returns RESULT or NON-RESULT
| From: | Karam Chand | Date: | Sat, 16 Oct 2004 08:36:23 +0000 |
| Subject: | Re: Best way to figure out whether a query returns RESULT or NON-RESULT | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-199628@lists.php.net to get a copy of this message | ||
Hello,
mysql_query() returns non-false even if there was an
UPDATE statement and the query was successful.
But if I put the $result variable in mysql_num_rows()
it returns an error, $result in invalid handle.
I was asking how to know that where its an UPDATE
statement so I dont call mysql_num_rows() at all.
The problem is that if I set error_reporting( 0 ),
everything works but we are required to have
error_reporting ( E_ALL )
Regards,
Karam
--- Chris <listschris@leftbrained.org> wrote:
> Karam Chand wrote:
>
> >Hello,
> >
> >I have an app where one module is similar to
> >phpMyAdmin (well only .1%) with error_reporting()
> set
> >to E_ALL.
> >
> >Now a user can execute any query. What is the best
> way
> >to know whether a query is result or non-result.
> >
> >e.g.
> >
> >
> >
> . . .
>
> >Thanks in advance
> >
> >Regards,
> >Karam
> >
> >
> >
>
> As it states on http://www.php.net/mysql_query :
>
> " Only for SELECT,SHOW,EXPLAIN or DESCRIBE
> statements *mysql_query()*
> returns a resource identifier or *FALSE* if the
> query was not executed
> correctly. For other type of SQL statements,
> *mysql_query()* returns
> *TRUE* on success and *FALSE* on error. A
> non-*FALSE* return value means
> that the query was legal and could be executed by
> the server."
>
> So , (false !== $result) means the query was
> sucessful , and if it was
> successful (true === $result) would mean that no
> rows were returned.
>
> Chris
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com