I am trying to use php to delete a record from a database. the code i am using is this:
<?php
require_once ('mysql_connect.php');
if (!isset($_GET['do']) || $_GET['do'] != 1) {
?>
<p align="center">
Are you sure you want to delete this <?php
echo $_GET['type']; ?>?<br>
<a href="<?php echo $_SERVER['REQUEST_URI']; ?>&do=1">Yes</a>
or <a href="view.php">View Databasebase</a>
</p>
<?php
} else {
// delete a record
$sql = "DELETE FROM 'Personel'
WHERE " . $_GET['type'] . "
LIMIT 1";
//echo SQL for debug purpose
echo "<!--" . $sql . "-->";
$result = mysql_query($sql)
or die("Invalid query: " . mysql_error() );
?>
<p align="center">
Your <?php echo $_GET['type']; ?> has been deleted.
<a href="view.php">View Database</a>
</p>
<?php
}
?>
as i am still getting to grips with php and mysql i have tried to adapt an example from a book to suit my own means, so its probably way off base. The error that is displayed is :
You have an error in your SQL syntax near ''Personel' WHERE Surname=Carrick LIMIT 1' at line 1
The database i ahve created consists of two fields a Surname and a Firstname. What i am trying to achieve is delete an entire person or row from the database!
<?php
require_once ('mysql_connect.php');
if (!isset($_GET['do']) || $_GET['do'] != 1) {
?>
<p align="center">
Are you sure you want to delete this <?php
echo $_GET['type']; ?>?<br>
<a href="<?php echo $_SERVER['REQUEST_URI']; ?>&do=1">Yes</a>
or <a href="view.php">View Databasebase</a>
</p>
<?php
} else {
// delete a record
$sql = "DELETE FROM 'Personel'
WHERE " . $_GET['type'] . "
LIMIT 1";
//echo SQL for debug purpose
echo "<!--" . $sql . "-->";
$result = mysql_query($sql)
or die("Invalid query: " . mysql_error() );
?>
<p align="center">
Your <?php echo $_GET['type']; ?> has been deleted.
<a href="view.php">View Database</a>
</p>
<?php
}
?>
as i am still getting to grips with php and mysql i have tried to adapt an example from a book to suit my own means, so its probably way off base. The error that is displayed is :
You have an error in your SQL syntax near ''Personel' WHERE Surname=Carrick LIMIT 1' at line 1
The database i ahve created consists of two fields a Surname and a Firstname. What i am trying to achieve is delete an entire person or row from the database!