Welcome to WebmasterWorld Guest from 107.22.7.35

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Help Please

     
10:06 pm on Aug 20, 2006 (gmt 0)

10+ Year Member



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.

10:12 pm on Aug 20, 2006 (gmt 0)

10+ Year Member



service_id = $serviceid);

service_id = '$serviceid'");

try that maybe...

-kpaul

10:20 pm on Aug 20, 2006 (gmt 0)

WebmasterWorld Senior Member eelixduppy is a WebmasterWorld Top Contributor of All Time 5+ Year Member



Hello!

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
?>

Good luck!

10:59 pm on Aug 20, 2006 (gmt 0)

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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... ;)

 

Featured Threads

Hot Threads This Week

Hot Threads This Month