Re: Resource id #34
| From: | Ryan Adams | Date: | Wed, 24 May 2000 18:36:37 +0000 |
| Subject: | Re: Resource id #34 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-462@lists.php.net to get a copy of this message | ||
This may not be what you're looking for, but it seems that you
need to extract the value from the result set before incrementing
it. This can be done with mysql_result() or mysql_fetch_array() or
similar.
e.g.
$MaxThread = "select max(thread) as Thread from message";
$r_MaxThread = mysql_query ($MaxThread, $mysql_link);
$MaxThreadVal = mysql_result ($r_MaxThread, 0, "Thread");
$MaxThreadVal++;
Hope this helps.
-Ryan
*************************************
Ryan Adams
Online Systems Development
College of Family & Consumer Sciences
The University of Georgia
Athens, GA 30602
(706) 583-0344
radams@fcs.uga.edu
*************************************
On Wed, May 24, 2000 at 05:26:55PM +0100, Will Macdonald wrote:
> Hi,
>
> I have this strange priblem when trying to get the maximum value from a
> MySQL database column..
>
> The code in question is this:
>
> $MaxThread = "SELECT MAX(Thread) AS Thread FROM message";
> $MaxThreadVal = mysql_query($MaxThread, $mysql_link);
>
> I want to increment the value held by $MaxThreadVal by one.
>
> print $MaxThreadVal;
> $MaxThreadVal++;
> print $MaxThreadVal;
>
> For debugging purposes I am printing before and after. However, I get
> Resource id #34 returned.
>
> I have checked the code with MySQL client and it works fine, returning
> the correct value. I am tailing the MySQL log and the following code is
> being passed to MySQL:
> 933 Query SELECT MAX(Thread) AS Thread FROM message
>
> I have many other SQL queries running in my code and they all work as
> they should.
>
> Can some one explain what this Resource id #34 means. I have tried
> searching with little success.
>
> Setup: Linux Mandrake, MySQL 3.23, PHP4.0, Zend Opt B4, Apache 1.3.12.
> PHP compiled as module.
>
> Thanks
>
> Will
>
>
> --
> mailto:wfm@macscan.co.uk
> http://www.williammacdonald.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
---end quoted text---