Link to home
Start Free TrialLog in
Avatar of digarati
digarati

asked on

1064 Error when trying to DELETE FROM table

Assistance needed for the following error:

Your request has been sent.
There was an error in your request. Please contact support and reference: 1064

Code is snipped.

The following script is deleting two records from two tables that are relationshiped by their id and key.

<?php
session_start();
if(!isset($_SESSION["sessioname"])){
header("location: http://www.site.com/beta/login2.html");
}else{
////////////////////////////////////////////////////////////////////////////////////////////////////MY PROTECTED CONTENT
include 'header.php';
require_once "dbconnection.php";
 
$id = ($_GET['id']);
 
$sql = "DELETE FROM vendor WHERE id= '$id'";
$sql2 = "DELETE FROM scope WHERE key= '$id'";
 
$res = mysql_query($sql,$mysql);
$res2 = mysql_query($sql2,$mysql);
$link="<a href=\"http://www.site.com/beta/home.php\">Return</a>";
 
 
//deleting vendor from database
if ($res === TRUE) {
            echo "<br/>";
			echo "Your request has been sent.<br/>";
			
			} else {
            printf("There was an error in your request. Please contact support and reference: %s\n", mysql_errno($mysql));
      }
	  
//deleting scope from database
if ($res2 === TRUE) {
            echo "<br/>";
			echo "Your request has been sent.<br/>";
			
			} else {
            printf("There was an error in your request. Please contact support and reference: %s\n", mysql_errno($mysql));
      }
     
}?>

Open in new window

Avatar of oku86
oku86
Flag of United Kingdom of Great Britain and Northern Ireland image

Regarding

if ($res === TRUE) {

it should be if ($res == TRUE) (

It should only be two equal signs
Avatar of digarati
digarati

ASKER

oku86 thanks for that update. was working. but this i guess is more formal.
i still have the 1064 error, anyone?
Try this:

$sql = "DELETE FROM `vendor` WHERE `id`= '$id'";
$sql2 = "DELETE FROM `scope` WHERE `key`= '$id'";

You get this error when you use reserved words from MySQL. I suspect it would be the "key" word in this case. To make sure you never get this problem again use the backtick character as in the code above.

You can find more informatiom about this on: http://dev.mysql.com/doc/refman/5.0/en/function-resolution.html
I now get the following error

Parse error: parse error, unexpected '=' in /home/content/site/html/beta/delete_vendor.php on line 12
ASKER CERTIFIED SOLUTION
Avatar of oku86
oku86
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
$sql = "DELETE FROM vendor WHERE id=$id";
$sql2 = "DELETE FROM scope WHERE `key`=$id";
what worked for me......
Im glad we managed to figure it out in the end :)