homepage Welcome to WebmasterWorld Guest from 54.205.254.108
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

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

-kpaul

eelixduppy




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

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!

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved