Hi Ben, first of all great thanks to you for this script and it is going to help me a lot at work. I was actually setting it up with our own database and added all the row names and so on. Editing, adding, viewing results works just fine. But the only problem I dealing with is when I try to delete any existing record. I believe that whenever I change
DELETE FROM content WHERE id_number=$id_number
in delete.php file ($id_number is the row in my custom database so had to change it), it shows different error each time. Right now if I have it like that then I get an error saying
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
But then If I change mysql_query to
DELETE FROM content WHERE id_number='$id_number'
then it will not delete that file but will redirect me to listed location. Would you please help me figure out the problem?
Here is the whole delete.php here if you need to go through it:
<?php
/*
DELETE.PHP
Deletes a specific entry from the 'content' table
*/
// connect to the database
include('connect-db.php');
// check if the 'id' variable is set in URL, and check that it is valid
if (isset($_GET['id_number']) && is_numeric($_GET['id_number']))
{
// get id value
$id = $_GET['id_number'];
// delete the entry
$result = mysql_query("DELETE FROM content WHERE id_number='$id_number'")
or die(mysql_error());
// redirect back to the view page
header("Location: view-paginated.php?page=4");
}
else
// if id isn't set, or isn't valid, redirect back to view page
{
header("Location: view-paginated.php?page=4");
}
?>
Basic Php System: View/edit/delete/add Records
in PHP
Posted
Hi Ben, first of all great thanks to you for this script and it is going to help me a lot at work. I was actually setting it up with our own database and added all the row names and so on. Editing, adding, viewing results works just fine. But the only problem I dealing with is when I try to delete any existing record. I believe that whenever I change
in delete.php file ($id_number is the row in my custom database so had to change it), it shows different error each time. Right now if I have it like that then I get an error saying
But then If I change mysql_query to
then it will not delete that file but will redirect me to listed location. Would you please help me figure out the problem?
Here is the whole delete.php here if you need to go through it:
Thank you in advance Mr. Falk.