RE: [PHP-DB] Check data exists in MySQL

From: Date: Thu, 21 Nov 2002 22:19:16 +0000
Subject: RE: [PHP-DB] Check data exists in MySQL
Groups: php.db 
Request: Send a blank email to php-db+get-23581@lists.php.net to get a copy of this message
Sorry about previous post (some stupid shortcut key made it send) Your row: $sql = "INSERT INTO count VALUES('$dept', '$deptsub', '0'); should be: $sql = "INSERT INTO count VALUES('$dept', '$deptsub', '0')"; You missed the double quotes. Adam --- Original Message --- Hi, for some reason i'm getting an error when I try to run this query: __________________________________ $sql="SELECT num FROM count where dept='$dept' AND deptsub='$deptsub'"; $page_count = mysql_query($sql,$db); # If does not exist in the database, insert a new entry if (!mysql_num_rows($page_count)){ $sql = "INSERT INTO count VALUES('$dept', '$deptsub', '0'); $result = mysql_query($sql,$db); } #Update the count in the database $page_count = $page_count + 1; $sql="UPDATE count SET num='$page_count' WHERE dept='$dept' AND deptsub='$deptsub'"; $result = mysql_query($sql, $db); __________________________________ My table looks like this: count: dept VARCHAR(32) deptsub VARCHAR(32) num INT(10) __________________________________ I'm getting the following error message: Parse error: parse error in /home/...../public_html/public/index.php on line 25 (Which is the line: $sql="UPDATE count...) Any thoughts would b most helpful. Thanks, Gav

« previous php.db (#23581) next »