> Currently, I have been counting the rows in PHP in order to get the value of
> the last hit_id in the database like this:
You have mysql_insert_id() in php to get the last autoincrement
value. This is _not_necessarily_ the same as the number of rows.
> It's staggering the difference in speed. But if I sit there and hit refresh
> on the browser, I get wildly different values for $pixels. It jumps around
> the actual number by +-10 or 12. The first method is precisely the same
> every time (unless a hit is recorded in the interim). Am I doing something
> wrong here?
Well, I imagine that the last inserted id (not number of rows)
will be given after you have actually inserted a row. I never
tried to ask twice.
Did you ever find that a variable in php shows a totally obscure
value? If so, you may find that the value was not defined at all
and point to some random memory block which contains some value
from another process which you see.
Maybe this is the case with mysql, too. So you better be sure to
look for what you refer to. I made a search on LAST_INSERT_ID but
it returned 0 results in mysql.com. Funny.
> Can I not count on MySQL to know how many rows it has recorded
> in a table? Any idea why that select statement would select a different row
> each time?
This is a different question. You should ask
SELECT count(*) as num FROM hits
and then look at the value of num to get an answer to that
question.
--
Herzlich
Werner Stuerenburg
_________________________________________________
ISIS Verlag, Teut 3, D-32683 Barntrup-Alverdissen
Tel 0(049) 5224-997 407 · Fax 0(049) 5224-997 409
http://pferdezeitung.de
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php