Sorry here is wut i did for the delete page....Me stupid..!
<?php
include "config.php";
include "functions.php";
if(isset($_GET['id'])){
$query = "SELECT * FROM photo WHERE id = '" . $_GET['id'] . "'";
//echo $query;
$result = mysql_query($query)or die("Could not SELECT DELETE ENTRY because" . mysql_error());
if(mysql_num_rows($result)>0){
$row = mysql_fetch_array($result);
}else{
header("Location: photos.php");
}
}
if(isset($_POST['submit'])){
$name = mysql_real_escape_string($_POST['name']);
$description = mysql_real_escape_string($_POST['comments']);
$query = "DELETE photo SET name='$name', comments='$description'
WHERE id ='" . $_POST['delete_id'] . "'";
//echo $query;
mysql_query($query)or die("Could not DELETE ENTRY:" . mysql_error());
header("Location: photos.php?status=DELETED");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../css/styleb.css" rel="stylesheet" type="text/css" />
<title>_ BACKHAND pour gerer photos |</title>
</head>
<body>
<div id="wrapper">
<div id="inside">
<h2>Delete Entry</h2>
<table>
<tr>
<th>Name</th>
<th>Comments</th>
<th></th>
</tr>
<tr>
<form action="<?=$_SERVER['PHP_SELF']?>" method="GET">
<td>
<input type="hidden" name="delete_id" value="<?=$row['id']?>" />
<input type="submit" name="delete" value="DELETE ENTRY" />
</form>
<br/>
<form action="photos.php" method="POST">
<input type="submit" name="cancel" value="CANCEL" />
</td>
</form>
</tr>
<?=$table_rows?>
</table>
</div>
</body>
This is my first month with php and my first day in here...
Moderator: General Moderators
-
Jeune griot
- Forum Newbie
- Posts: 4
- Joined: Fri Jun 27, 2008 1:10 pm
This is my first month with php and my first day in here...
Last edited by Jeune griot on Fri Jun 27, 2008 2:11 pm, edited 4 times in total.
Re: This is my first month with php and my first day in here...
You don't appear to have any delete code in that script. That would explain why it doesn't work.
-
Jeune griot
- Forum Newbie
- Posts: 4
- Joined: Fri Jun 27, 2008 1:10 pm
Re: This is my first month with php and my first day in here...
Well the page u r actually seeing is my edit page wich is working... I did exactly the same for the delete one but it doesnt work. Does anyone can help me with a right way to do a delete page
Re: This is my first month with php and my first day in here...
Did you actually look up the syntax for a DELETE in SQL? What you have there should be..
Code: Select all
$query = "DELETE FROM photo WHERE id ='" . $_POST['delete_id'] . "'";-
Jeune griot
- Forum Newbie
- Posts: 4
- Joined: Fri Jun 27, 2008 1:10 pm
Re: This is my first month with php and my first day in here...
this is the result on the
http:// .........../delete.php?delete_id=197&delete=DELETE+ENTRY
but it doesnt delete anything. I dont understand.
http:// .........../delete.php?delete_id=197&delete=DELETE+ENTRY
but it doesnt delete anything. I dont understand.
Re: This is my first month with php and my first day in here...
Read what onion2k just showed you. If your SQL syntax is incorrect, it's not going to work. What's to understand?
-
Jeune griot
- Forum Newbie
- Posts: 4
- Joined: Fri Jun 27, 2008 1:10 pm
Re: This is my first month with php and my first day in here...
Well thank you for the try but even that syntax doesnt work. Thank you all anyway.
Re: This is my first month with php and my first day in here...
The problem is with your form.. you're submitting the delete request as GET, but in the PHP you check "if(isset($_POST['submit'])){". $_POST won't be set if you use a GET request.
Read this - http://www.ibm.com/developerworks/library/os-debug/ - It's a really good guide to tracking down problems in your scripts. Just ignore the stuff about Eclipse if you don't use that.
Read this - http://www.ibm.com/developerworks/library/os-debug/ - It's a really good guide to tracking down problems in your scripts. Just ignore the stuff about Eclipse if you don't use that.