Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 17th, 2009, 08:44 AM
Registered User
 
Join Date: Apr 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Angry Delete not working

an someone please tell me why isnt my delete working?

PHP Code:
<?php
include('includes/config.php');
echo 
$_REQUEST['id'];
if (isset(
$_REQUEST['submit']) && $_REQUEST['submit'] == "Delete") {
?>
<form action="slett_ansvarlig.php?id=<?php echo $_REQUEST['id']; ?>" method="post">
<?php
$sql 
"DELETE * FROM ansvarlig where a_id=" $_REQUEST['id'];
$result mysql_query($sql)
         or die(
'Could not delete; ' mysql_error());
}
?>
<input type="submit" value="Delete" />
</form>
i do get a value when i run:

PHP Code:
echo $_REQUEST['id']; 
 
Old April 24th, 2009, 12:37 PM
Authorized User
 
Join Date: Mar 2009
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default mysql error

I think you may need a database conncection id here for php5+ :
$result
= mysql_query($sql);

$result = mysql_query($sql, $dbconnid);

otherwise next step would be to echo out the query to the screen, then cut and past it into your mysql admin window and see if it works there.

and you are doing a method=POST, not a GET.
rather set your request id as a input type=hidden varaible, and it'll be there upon post.

cheers. -m
---
 
Old May 7th, 2009, 03:00 PM
Authorized User
 
Join Date: Nov 2008
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default This might help you.

You must pass the connection Identifier.visit http://in.php.net/manual/en/function.mysql-query.php





Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Button not working in Wrox CMS VB Sojan80 BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 3 June 16th, 2007 03:23 AM
delete is not working thas123 ADO.NET 1 January 6th, 2006 09:41 AM
Delete query not working Mitch PHP Databases 4 January 4th, 2006 08:00 AM
Delete Query not working kbonney98 Access 1 April 14th, 2005 06:29 AM
Edit/Delete ButtonColumn not working planoie ASP.NET 1.0 and 1.1 Professional 9 August 30th, 2004 07:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.