Hi
On my way to bed so too tired too look closely, but at a guess I'd say
it's a logic error. I would guess this:
$sid = mysql_fetch_array($query) || die ('Could not fetch from database:
' . mysql_error()); // --- line 49
isn't evaluating in the order you expect.. You're using
I have a table where I need to figure out the very first ID and the
very last ID, so here is what I wrote:
$first_query = SELECT id FROM mytable ORDER BY id LIMIT 1;
$first_result = mysql_query($first_query,$con);
$first_id = mysql_result($first_result,0,'id');
$last_query = SELECT id FROM
SELECT MIN(id), MAX(id) FROM mytable
:)
Hope that helps!
-TG
= = = Original message = = =
I have a table where I need to figure out the very first ID and the
very last ID, so here is what I wrote:
$first_query = SELECT id FROM mytable ORDER BY id LIMIT 1;
$first_result =
lameck kassana [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
hey just make this
$sid = mysql_fetch_array($query) or die ('Could not fetch from database:
' . mysql_error().);
try this
Yep. I figured that out yesterday. Hit the nail right on the head. As
I've learned from
[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
SELECT MIN(id), MAX(id) FROM mytable
As an aside, is you are using associative arrays, be sure to use the
following keys:
$array['MIN(id)'] and $array['MAX(id)']
Just something I figured out recently :)
Matt
--
PHP Database
Sounds about right... you can also do something like this (syntax should be
right):
SELECT MIN(id) as minid, MAX(id) as maxid FROM mytable
$array['minid'] and $array['maxid']
Basically it's going to be whatever the heading of that column is. Using as
gives it an alias for less ugly
On Wed, 11 Jul 2007, Matt Leonhardt wrote:
[EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
SELECT MIN(id), MAX(id) FROM mytable
As an aside, is you are using associative arrays, be sure to use the
following keys:
$array['MIN(id)'] and $array['MAX(id)']
Just something I figured