DB will INSERT wont UPDATE..error in code?

From: Date: Tue, 12 Oct 2004 20:08:42 +0000
Subject: DB will INSERT wont UPDATE..error in code?
Groups: php.db 
Request: Send a blank email to php-db+get-36762@lists.php.net to get a copy of this message
forgive the poor structure of my code, im pretty new at this and havent figured out exactly what it should be formed like to look its best, anyway whenever i run this code it works on inserting new information into the database, however when i want to update the SQL query returns an output like this 'SQL statement = UPDATE badges (staff,ttlpst,mnthpst,ttlicon,mnthicon) VALUES ('1','1','1','/ribbons','/ribbons') WHERE fid=2' but when i try to pull the information from the database it hasnt updated, can someone help me out with this...im not sure why it wouldnt update even though the statement looks correct. if (empty($form_status)){ $staff = $HTTP_POST_VARS["staff"]; $ttlpst = $HTTP_POST_VARS["ttlpst"]; $mnthpst = $HTTP_POST_VARS["mnthpst"]; $ttlicon = $HTTP_POST_VARS["ttlicon"]; $mnthicon = $HTTP_POST_VARS["mnthicon"]; $exists = "SELECT * FROM badges WHERE fid = $fid"; $result = mysql_query($exists); if (mysql_num_rows($result) == 0) { $sql = "INSERT INTO badges (fid,staff,ttlpst,mnthpst,ttlicon,mnthicon) VALUES ('$fid','$staff','$ttlpst','$mnthpst','$ttlicon','$mnthicon')"; db_query($sql); $form_status = "<span class=\"msgUpdated\">Description Updated!</span><br>\n"; } else { $sql = "UPDATE badges SET staff = '".$HTTP_POST_VARS["staff"]."' ttlpst = '".$HTTP_POST_VARS["ttlpst"]."' mnthpst = '".$HTTP_POST_VARS["mnthpst"]."' ttlicon = '".$HTTP_POST_VARS["ttlicon"]."' mnthicon = '".$HTTP_POST_VARS["mnthicon"]."' WHERE fid = $fid"; db_query($sql); $form_status = "<span class=\"msgUpdated\">Description Updated!</span><br>\n"; } }

« previous php.db (#36762) next »