Re: invalid resource for fetch_object??
| From: | Jason Wong | Date: | Wed, 30 Apr 2003 18:06:25 +0000 |
| Subject: | Re: invalid resource for fetch_object?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-145833@lists.php.net to get a copy of this message | ||
On Thursday 01 May 2003 00:39, Prince wrote:
> mysql_query("select count(*) from prayer");
> $total=mysql_affected_rows();
> also i get only 1 records found when it sends me mail about what the script
> had done and found when i know there are 5 records in the table??
$total contains the affected rows which is meaningless given that your query
is a COUNT(*). You can either:
SELECT * FROM prayer; then use mysql_num_rows()
OR
SELECT COUNT(*) FROM prayer; then use mysql_fetch_array() and get the value
of the first element.
> $status1=mysql_query("select version() as version, connection_id() as
> connection, now() as time, benchmark(1, \"delete from prayer where Posted
> <= now()-interval 14 day\") as bench");
> on the $status1= line it takes the version number time and all that sort of
> stuff and then does a query for a delete from a table it then takes the
> select on the $status1 line and tries to do a fetch_object on the select
> but for some reason i get a invalid resource for that function?? how come
> when i can do the work manual but the php script says that?
Assign your query to a variable. echo() that variable to ensure that the query
looks OK and copy & paste that into the mysql commandline to see whether it
works. Error check what's being returned from mysql_query() and use
mysql_error().
> would fetchJ_array or fetch_row be better for that?
These return different things so you really can't compare them.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Using TSO is like kicking a dead whale down the beach.
-- S.C. Johnson
*/