nonexistentera Posted July 5, 2009 Share Posted July 5, 2009 I have no idea how this happens. I have tried the SQL straight through phpMyAdmin and it works perfectly, but yet when I try it through the script, it deletes the row instead of just updating it. It is set into a function below function Confirm(){ global $HTTP_SERVER_VARS, $user_info; $id = $_GET["id"]; $md5 = $_GET["secret"]; if (!$id) httperr(); $res = mysql_query("SELECT passhash, editsecret, status FROM users WHERE id = $id"); $row = mysql_fetch_array($res); if (!$row) httperr(); if ($row["status"] != "pending") { header("Refresh: 0; url=/ok?type=confirmed"); exit(); } $sec = hash_pad($row["editsecret"]); if ($md5 != md5($sec)) httperr(); $updateSQL = "UPDATE `users` SET `status` = 'confirmed' WHERE `id` =".$id." LIMIT 1 "; mysql_query($updateSQL) or die(mysql_error()); logincookie($id, $row["passhash"]); header("Location: /ok?type=confirm"); } I have tried the $updateSQL and it returns no errors, but the mysql_query is deleting it. Any thoughts on why this would be doing this ??? Quote Link to comment https://forums.phpfreaks.com/topic/164880-solved-php-mysql_query-update-deletes-row/ Share on other sites More sharing options...
nonexistentera Posted July 6, 2009 Author Share Posted July 6, 2009 bump Quote Link to comment https://forums.phpfreaks.com/topic/164880-solved-php-mysql_query-update-deletes-row/#findComment-869857 Share on other sites More sharing options...
AwptiK Posted July 6, 2009 Share Posted July 6, 2009 `'s Quote Link to comment https://forums.phpfreaks.com/topic/164880-solved-php-mysql_query-update-deletes-row/#findComment-869893 Share on other sites More sharing options...
PFMaBiSmAd Posted July 6, 2009 Share Posted July 6, 2009 Your last header() redirect needs an exit; statement after it to prevent the remainder of the code on the page from being executed, which I will guess is a DELETE query. Your existing code is executing the UPDATE query, executing the header() redirect, the confirm() function returns to the code that called it, and the rest of the logic on that page is executed. Quote Link to comment https://forums.phpfreaks.com/topic/164880-solved-php-mysql_query-update-deletes-row/#findComment-869897 Share on other sites More sharing options...
nonexistentera Posted July 7, 2009 Author Share Posted July 7, 2009 Well thank you for your suggestion. I did exactly as you said, and it still didn't work. After a few cups of coffee, and some holes in the wall, I finally found the issue. I have a function that deletes users that have not been confirmed after 24 hours, and this is added into my database connection function. I had the function in my global call file setting clean as true, which deleted the user once the file was called. This was my bad XD Thank you for your help, I have always liked this community Thanks -nonexistentera Quote Link to comment https://forums.phpfreaks.com/topic/164880-solved-php-mysql_query-update-deletes-row/#findComment-870504 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.