maxudaskin Posted July 15, 2007 Share Posted July 15, 2007 I use $sql2 = "DELETE FROM `applications` WHERE `id` = '{$id}' LIMIT 1;"; to delete a row from a database. It does not end up deleting it, but it does not produce an error. <?php $accept = $_REQUEST["accept"]; $deny = $_REQUEST["deny"]; if(isset($accept)) { $id = $_REQUEST["appid"]; $hub = $_REQUEST["hub"]; $temppid = rand(1001,3999); $fname = $_REQUEST["fname"]; $lname = $_REQUEST["lname"]; $email = $_REQUEST["email"]; $pass = $_REQUEST["pass"]; $position = $_REQUEST["position"]; $type = $_REQUEST["role"]; $appdate = $_REQUEST["appdate"]; $birthday = $_REQUEST["birthday"]; $country = $_REQUEST["country"]; $vatsim = $_REQUEST["vatsim"]; $ivao = $_REQUEST["ivao"]; $ip = $_REQUEST["ip"]; $result = mysql_query("SELECT * FROM `users` WHERE `pid`='{$temppid}'"); if (mysql_num_rows($result) == 1) { $pidcheck = 1; } else { $pidcheck = 0; } do { $$temppid++; } while ($pidcheck==1); if ($pidcheck==0); { $pid = $temppid; $sql="INSERT INTO users (appid, fname, lname, email, pass, hub, birthday, country, vatsim, ivao, position, ip, acceptdate, appdate, type, pid) VALUES ('$id','$fname','$lname','$email','$pass','$hub','$birthday','$country','$vatsim','$ivao','$position','$ip', NOW( ), '$appdate', '$type', $pid)"; if (!mysql_query($sql,$LeadHost)) { die('Error: ' . mysql_error()); } echo "1 user added..."; echo "<br>"; echo "</br>"; echo "Thank you For Using Max Udaskin's Virtual Airline Administration Script."; $subject = "Application Accepted" ; $message = "Hello ".$fname." ".$lname.", Your application to Virtual Zoom Airlines has been accepted. You may now login to the website using the user name and password you registered with: Pilot ID: ".$temppid." Password: ".$password." Be sure to register for the forums and check out the latest NOTAMS before your first flight. Feel free to contact us for assistance, but please do not reply to this email. Regards, Virtual ZOOM Airlines Management"; mail($email, "Subject: $subject", $message, "From: Virtual Zoom Airlines" ); } } elseif (isset($deny)) { mysql_select_db($database_LeadHost, $LeadHost); $id = $_GET['apps']; $sql2 = "DELETE FROM `applications` WHERE `id` = '{$id}' LIMIT 1;"; if (!mysql_query($sql2,$LeadHost)) { die('Error: ' . mysql_error()); } echo "Application Denied and Deleted."; } ?> Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 15, 2007 Share Posted July 15, 2007 First off, you have an extra semi-colon in there, so first try this: $sql2 = "DELETE FROM `applications` WHERE `id` = '$id' LIMIT 1"; If that doesn't work, try removing the limit 1: $sql2 = "DELETE FROM `applications` WHERE `id` = '$id'"; Quote Link to comment Share on other sites More sharing options...
maxudaskin Posted July 15, 2007 Author Share Posted July 15, 2007 First off, you have an extra semi-colon in there, so first try this: $sql2 = "DELETE FROM `applications` WHERE `id` = '$id' LIMIT 1"; If that doesn't work, try removing the limit 1: $sql2 = "DELETE FROM `applications` WHERE `id` = '$id'"; Didn't work... Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted July 15, 2007 Share Posted July 15, 2007 Try replacing this code: <?php $sql2 = "DELETE FROM `applications` WHERE `id` = '{$id}' LIMIT 1;"; if (!mysql_query($sql2,$LeadHost)) { die('Error: ' . mysql_error()); } echo "Application Denied and Deleted."; ?> With: <?php $sql2 = "DELETE FROM `applications` WHERE `id` = '$id'"; if (mysql_query($sql2,$LeadHost)){ echo "Application Denied and Deleted."; } else { die('Error: ' . mysql_error()); } ?> Quote Link to comment Share on other sites More sharing options...
maxudaskin Posted July 15, 2007 Author Share Posted July 15, 2007 Nope... Nothing works... Quote Link to comment Share on other sites More sharing options...
drewbee Posted July 15, 2007 Share Posted July 15, 2007 Why do you have those bac-tic things in their? the tablename and column names should not be enclosed in quotes. Also, you should always escape any variables going into a SQL command to help protect against SQL injection, even if that variable is coming from another query. $sql1 = "DELETE FROM applications WHERE id = '".mysql_real_escape_string($id)."' Let me know... Quote Link to comment Share on other sites More sharing options...
maxudaskin Posted July 15, 2007 Author Share Posted July 15, 2007 Nothing is working... ??? Quote Link to comment Share on other sites More sharing options...
drewbee Posted July 15, 2007 Share Posted July 15, 2007 In your code near this delete line, you have a mysql_select_db. Where is your connect string at? Also, try just putting the string directly into the mysql_query function. mysql_query("DELETE FROM applications WHERE id = '".mysql_real_escape_string($id)."'"); Quote Link to comment Share on other sites More sharing options...
maxudaskin Posted July 15, 2007 Author Share Posted July 15, 2007 <?php require_once('Connections/LeadHost.php'); ?> <?php mysql_select_db($database_LeadHost, $LeadHost); ?> Quote Link to comment Share on other sites More sharing options...
maxudaskin Posted July 15, 2007 Author Share Posted July 15, 2007 The INSERT INTO works but the DELETE FROM doesn't. <?php $accept = $_REQUEST["accept"]; $deny = $_REQUEST["deny"]; if(isset($accept)) { $id = $_REQUEST["appid"]; $hub = $_REQUEST["hub"]; $temppid = rand(1001,3999); $fname = $_REQUEST["fname"]; $lname = $_REQUEST["lname"]; $email = $_REQUEST["email"]; $pass = $_REQUEST["pass"]; $position = $_REQUEST["position"]; $type = $_REQUEST["role"]; $appdate = $_REQUEST["appdate"]; $birthday = $_REQUEST["birthday"]; $country = $_REQUEST["country"]; $vatsim = $_REQUEST["vatsim"]; $ivao = $_REQUEST["ivao"]; $ip = $_REQUEST["ip"]; $result = mysql_query("SELECT * FROM `users` WHERE `pid`='{$temppid}'"); if (mysql_num_rows($result) == 1) { $pidcheck = 1; } else { $pidcheck = 0; } do { $$temppid++; } while ($pidcheck==1); if ($pidcheck==0); { $pid = $temppid; $sql="INSERT INTO users (appid, fname, lname, email, pass, hub, birthday, country, vatsim, ivao, position, ip, acceptdate, appdate, type, pid) VALUES ('$id','$fname','$lname','$email','$pass','$hub','$birthday','$country','$vatsim','$ivao','$position','$ip', NOW( ), '$appdate', '$type', $pid)"; if (!mysql_query($sql,$LeadHost)) { die('Error: ' . mysql_error()); } echo "1 user added..."; echo "<br>"; echo "</br>"; echo "Thank you For Using Max Udaskin's Virtual Airline Administration Script."; $subject = "Application Accepted" ; $message = "Hello ".$fname." ".$lname.", Your application to Virtual Zoom Airlines has been accepted. You may now login to the website using the user name and password you registered with: Pilot ID: ".$temppid." Password: ".$password." Be sure to register for the forums and check out the latest NOTAMS before your first flight. Feel free to contact us for assistance, but please do not reply to this email. Regards, Virtual ZOOM Airlines Management"; mail($email, "Subject: $subject", $message, "From: noreply@virtualzoom.net" ); } } elseif (isset($deny)) { mysql_select_db($database_LeadHost, $LeadHost); $id = $_GET['appid']; if (mysql_query("DELETE FROM applications WHERE id = '".mysql_real_escape_string($id)."'")){ echo "Application Denied and Deleted."; } else { die('Error: ' . mysql_error()); } $subject = "Application Denied" ; $message = "Hello ".$fname." ".$lname.", Your application to Virtual Zoom Airlines has been accepted. You may now login to the website using the user name and password you registered with: Pilot ID: ".$temppid." Password: ".$password." Be sure to register for the forums and check out the latest NOTAMS before your first flight. Feel free to contact us for assistance, but please do not reply to this email. Regards, Virtual ZOOM Airlines Management"; mail($email, "Subject: $subject", $message, "From: noreply@virtualzoom.net" ); } ?> Quote Link to comment Share on other sites More sharing options...
maxudaskin Posted July 15, 2007 Author Share Posted July 15, 2007 Found the error...I used GET when I should have used POST. To prevent any further stupidness from me, I am now using REQUEST! Quote Link to comment Share on other sites More sharing options...
drewbee Posted July 15, 2007 Share Posted July 15, 2007 lol, that was the next step was to output the command to see what is actually being queried Nice job mate. Quote Link to comment 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.