PHP problems

He has: 1,380 posts

Joined: Feb 2002

ok, i know i posted related to this already...but, i can't get it to work. i created the table and db that this code corresponds to, but it wont register

i have this in my page:

<!-- Hidden Counter -->
<!--#exec cgi="/php/counter.php"-->
<!-- End Hidden Counter -->
'

and this is the PHP file:

<?php
$con
= @mysql_connect(\"localhost\",\"...\",\"...\");
if (!@mysql_select_db(\"...\",
$con)) die (\"Could not connect to database at this time\");
if (!@mysql_query(\"UPDATE counter SET number=number+1\")) die (\"Error running mysql_query. MySQL Error:\".mysql_error());
mysql_close(
$con);
?>

anybody know why its not working? thanks

They have: 447 posts

Joined: Oct 1999

does table counter have a record in it?

They have: 447 posts

Joined: Oct 1999

you don't really need to use a table and establish a database connection just to keep a count, something like this would work fine:

<?php
    $cnt
= @fread(fopen('./counter.txt', 'r'), 100);
   
fwrite(fopen('./counter.txt', 'w'), ++$cnt);
?>

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.