merylvingien Posted November 16, 2009 Share Posted November 16, 2009 Am i right in thinking that this statement should increase the mailcount by 1 $sql = "UPDATE table SET mailcount = mailcount + 1 WHERE value=$value"; Its adding 2 for some reason? Quote Link to comment https://forums.phpfreaks.com/topic/181773-solved-update-1/ Share on other sites More sharing options...
Daniel0 Posted November 16, 2009 Share Posted November 16, 2009 You're probably executing the query twice. Try posting the code. Quote Link to comment https://forums.phpfreaks.com/topic/181773-solved-update-1/#findComment-958667 Share on other sites More sharing options...
merylvingien Posted November 16, 2009 Author Share Posted November 16, 2009 if (!isset($_POST['emailid'])) {echo 'There appears to be a problem, please go back and try again.'; exit;} else if (isset($_POST['emailid'])) {$emailid= $_POST['emailid'];} $emailid= mysql_real_escape_string($emailid, $con); $emailid= htmlspecialchars($emailid); if (strlen($emailid) >5) {echo 'There appears to be a problem, please go back and try again.'; exit;} else $sql = ("SELECT * FROM postcode WHERE postcodeID='$emailid'")or die ('<p>There seems to be a problem, please try again.</p>'); $result = mysql_query($sql,$con); $row = mysql_fetch_assoc($result); $name = $_POST["name"]; $from = "[email protected]"; $contact = $_POST['contact']; $message = $_POST["message"]; $verif_box = $_REQUEST["verif_box"]; $name = stripslashes($name); $message = stripslashes($message); $from = stripslashes($from); if(md5($verif_box).'a4xn' == $_COOKIE['tntcon']){ $sql = "UPDATE postcode SET mailcount = mailcount + 1 WHERE postcodeID=$emailid"; mysql_query($sql) or trigger_error('<p>There seems to be a problem, please try again soon.</p>'); $result = mysql_query($sql); mail("{$row['email']}", 'some message ', "\n $name just sent you a message \n Their email address is: $contact \n Their message is: $message " , "From: $from" ); setcookie('tntcon',''); } else { // if verification code was incorrect then return to contact page and show error header("Location:".$_SERVER['HTTP_REFERER']."?subject=$subject&from=$from&message=$message&wrong_code=true"); exit; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/181773-solved-update-1/#findComment-958672 Share on other sites More sharing options...
Daniel0 Posted November 16, 2009 Share Posted November 16, 2009 Right, you are actually calling it twice: $sql = "UPDATE postcode SET mailcount = mailcount + 1 WHERE postcodeID=$emailid"; mysql_query($sql) or trigger_error('<p>There seems to be a problem, please try again soon.</p>'); $result = mysql_query($sql); Of course it'll update twice when you call it twice. Quote Link to comment https://forums.phpfreaks.com/topic/181773-solved-update-1/#findComment-958675 Share on other sites More sharing options...
merylvingien Posted November 16, 2009 Author Share Posted November 16, 2009 Doh!!!!!!! Ok once again i get the idots cap for the evening. I must be up for a tee shirt by now Quote Link to comment https://forums.phpfreaks.com/topic/181773-solved-update-1/#findComment-958676 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.