From what I've seen you didn't actually transmit the first query to
the database.
You assigned the query string to the variable $sql ... but didn't
submit with:
mysql_query($sql);

hth
richard

Sunday, April 18, 2004, 7:41:47 PM, thus was written:
> A basic ht counter script from Meloni's book on mysql (page 318).

> Not working for me.
> Every time I load the page the counter stays at zero.

> Thanks for help.
> TR
> ..................

> <?
> $page_name="test1";
> $db=mysql_connect("localhost","root",'mypass");
> mysql_select_db("sitename");
> $sql = "UPDATE test_track SET hits = hits + 1 WHERE page_name =
> '$page_name';
> $sql2="SELECT hits FROM test_track WHERE page_name='$page_name'";
> $res=mysql_query($sql2);
> $hits = mysql_result($res,0,'hits');
?>>
> <html>
> <body>
> <h1>You have been counted.</h1>
> <p>
> The current number is <? echo "$hits"; ?></p>
> </body>
> </html>
> .........

> // mysql SCHEMA

> CREATE TABLE test_track(
> id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
> page_name VARCHAR(50),
> hits INT
> );

> INSERT INTO test_track VALUES(1,'test1',0);
> ........

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to