Welcome to WebmasterWorld Guest from 188.8.131.52 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
Help Please puckparches msg:3053854 10:06 pm on Aug 20, 2006 (gmt 0) Can someone please take a look a this code and give an idea what i'm soing wrong. I;m trying to deleate a record but I can do it.
//session_start(); include_once("mysql_connect.php"); $myConn = connect_db();
$serviceid = $_POST['serviceid'];
$delete = mysql_query("DELETE * FROM service WHERE service_id = $serviceid);
mysql_query($strSQL, $myConn) or die (mysql_error());
echo "<script>alert('" . $intIndex . " Service Deleted!');</script>"; echo "<script>location.href='mycar.php';</script>";
I get a syntax error unexpected '>'
Thank you any help.
kpaul msg:3053856 10:12 pm on Aug 20, 2006 (gmt 0)
service_id = $serviceid);
service_id = '$serviceid'");
try that maybe...
eelixduppy msg:3053860 10:20 pm on Aug 20, 2006 (gmt 0)
Try something like this:
<? //connect to db $serviceid = $_POST['serviceid']; $query = "DELETE FROM service WHERE service_id = $serviceid"; mysql_query($query) or die (mysql_error()); ?> <script> alert("<? echo $intIndex;?>Service Deleted!"); location.href='mycar.php'; </script> <? //rest of code ?>
whoisgregg msg:3053879 10:59 pm on Aug 20, 2006 (gmt 0)
When I programatically delete from a DB, I prefer to limit the damage risk by adding in a LIMIT to how many rows could be deleted. I'm also a fan of backticking everything.
$query = "DELETE FROM `service` WHERE `service_id` = $serviceid LIMIT 1";
Just in case... ;)