For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > February 2005 > MySql / php newbie question: retrieving results that are not record sets









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author MySql / php newbie question: retrieving results that are not record sets
Martien van Wanrooij

2005-02-26, 3:56 pm

Hi,

I am trying to get familiar with MySql and what I noticed is that, when I
use other queries then just recordsets, with e.g. a select count in it, it
always leads to error messages like "mysql_fetch_row(): supplied argument is
not a valid MySQL result resource in ..." . Neither could I find any info
about php functions that could return the results of such "non-recordset"
queries. Other examples are "select 12/3" . Not that I would use MySql in
the future for doing calculations in php, because php has enough arithmetic
functions of its own, I just wonder if it is possible at all.
On the other hand I think it would be practical when you actually can make
php return the resuls of a "select count.. " query.
Thanks for any help.

Martien


Martien van Wanrooij

2005-02-26, 3:56 pm

Sorry maybe the question sounds unclear but I forgot to say that I am using
a simple php script to view the results.


Yevgen Varavva

2005-02-26, 3:56 pm


"Martien van Wanrooij" <info@martienvanwanrooij.nl> сообщил/сообщила в
новостях следующее: news:KH%Td.3387$Mw3.1702@amstwist00...
> Sorry maybe the question sounds unclear but I forgot to say that I am
> using a simple php script to view the results.

Try putting
====================
echo mysql_error();
====================
after your mysql_query() line.


Michael Fesser

2005-02-26, 3:56 pm

.oO(Martien van Wanrooij)

>I am trying to get familiar with MySql and what I noticed is that, when I
>use other queries then just recordsets, with e.g. a select count in it, it
>always leads to error messages like "mysql_fetch_row(): supplied argument is
>not a valid MySQL result resource in ..." .


You need a proper error handling. After sending the query check the
return value of mysql_query() and print out mysql_error() if necessary.
Without that you will never be able to track down the real problem.

>Neither could I find any info
>about php functions that could return the results of such "non-recordset"
>queries. Other examples are "select 12/3" . Not that I would use MySql in
>the future for doing calculations in php, because php has enough arithmetic
>functions of its own, I just wonder if it is possible at all.


Sure, 'SELECT 12/3' works very well.

>On the other hand I think it would be practical when you actually can make
>php return the resuls of a "select count.. " query.


It does. And it does even more, you just have to use the given
informations, especially in case of an error. RTFM.

Micha
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com