FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » MAX(id)
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
MAX(id) [message #177254] Thu, 01 March 2012 18:30 Go to next message
cerr is currently offline  cerr
Messages: 33
Registered: September 2010
Karma: 0
Member
Hi,

I have a query to figure out the max ID in a table. The code looks
like this:
$subquery = "SELECT MAX(id) FROM `xymply_markers`";
if (!$subresult = mysql_query($query)){
die('Error: ' . mysql_error());
}
if($max = mysql_fetch_array($subresult)){
var_dump($max);
}
Now this query gives me a nice result in phpMyAdmin but here I get a
sh*tload of data from my var_dump(), why is that?
How do I correctly read out the highest id number?
Thank you!
Ron
Re: MAX(id) [message #177255 is a reply to message #177254] Thu, 01 March 2012 18:38 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(cerr)

> I have a query to figure out the max ID in a table. The code looks
> like this:
> $subquery = "SELECT MAX(id) FROM `xymply_markers`";
> if (!$subresult = mysql_query($query)){
> die('Error: ' . mysql_error());
> }
> if($max = mysql_fetch_array($subresult)){
> var_dump($max);
> }
> Now this query gives me a nice result in phpMyAdmin but here I get a
> sh*tload of data from my var_dump(), why is that?

What is a "sh*tload" of data? How much and what do you get?

From your usage of mysql_fetch_array() I would expect an array with two
elements as the result.

> How do I correctly read out the highest id number?

See the manual for how to control what mysql_fetch_array() returns.
Or use another mysql_fetch_* function.

Micha

--
http://mfesser.de/blickwinkel
Re: MAX(id) [message #177256 is a reply to message #177255] Thu, 01 March 2012 19:01 Go to previous message
cerr is currently offline  cerr
Messages: 33
Registered: September 2010
Karma: 0
Member
On Mar 1, 10:38 am, Michael Fesser <neti...@gmx.de> wrote:
> .oO(cerr)
>
>> I have a query to figure out the max ID in a table. The code looks
>> like this:
>> $subquery = "SELECT MAX(id) FROM `xymply_markers`";
>>                    if (!$subresult = mysql_query($query)){
>>                            die('Error: ' . mysql_error());
>>                    }
>>                    if($max = mysql_fetch_array($subresult)){
>>                            var_dump($max);
>>                    }
>> Now this query gives me a nice result in phpMyAdmin but here I get a
>> sh*tload of data from  my var_dump(), why is that?
>
> What is a "sh*tload" of data? How much and what do you get?
>
> From your usage of mysql_fetch_array() I would expect an array with two
> elements as the result.

That's what I would have expected too...
>
>> How do I correctly read out the highest id number?
>
> See the manual for how to control what mysql_fetch_array() returns.
> Or use another mysql_fetch_* function.

Yep,

my bad. Figured it out...
Thanks for your time anyways!
--
cerr
www.inetgate.ca
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: javascript, XmlHttpRequest, PHP, and daemon
Next Topic: Name of page itself?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Mon Nov 25 03:42:11 GMT 2024

Total time taken to generate the page: 0.02507 seconds