Counter Help

From: Date: Fri, 23 Feb 2001 00:10:48 +0000
Subject: Counter Help
Groups: php.general 
Request: Send a blank email to php-general+get-41243@lists.php.net to get a copy of this message
Can someone help me with this script? It is an example from weberdev.com. I ran it and it gave me the following error... -- Warning: Use of undefined constant count - assumed 'count' in c:\windows\desktop\localhost\examples\counter\counter1.php on line 27 25 The number 25 is the correct number for the counter, but how do I get rid of that error message that keeps coming up before the counter number (25)? I am testing and learning PHP on Windows ME and am using PHP 4.0.4 with MySQL 3.23.33. Here is the script: <HTML> <HEAD> <TITLE></TITLE> </HEAD> <BODY> <!-- This example from http://www.weberdev.com/index.php3?GoTo=ShowShoppingItems.php3%3FMasterCateg --> <?php $hostname = 'localhost'; $username = 'username'; $password = 'password'; $dbName = 'database'; MYSQL_CONNECT($hostname,$username,$password) OR DIE("Unable to connect to database"); @mysql_select_db("$dbName") or die("Unable to select database"); $name = "$SCRIPT_NAME"; $result = MYSQL_QUERY("SELECT * FROM counter WHERE (name = '$name')") or die ("Bad query: ".mysql_error()); $row = mysql_fetch_array($result); if($row){ MYSQL_QUERY("UPDATE counter SET count = count+1 WHERE (name = '$name')") or die ("Bad query: ".mysql_error()); $count = $row[count]; }else{ MYSQL_QUERY("INSERT INTO counter VALUES ('', '$name', '2')") or die ("Bad query: ".mysql_error()); $count = '1'; } echo $count; ?> </BODY> </HTML> -- Navid

« previous php.general (#41243) next »