Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

1064 Error when trying to DELETE FROM table

Posted on 2008-06-17
7
Medium Priority
?
485 Views
Last Modified: 2013-12-12
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

0
Comment
Question by:digarati
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 1

Expert Comment

by:oku86
ID: 21804327
Regarding

if ($res === TRUE) {

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

It should only be two equal signs
0
 
LVL 1

Author Comment

by:digarati
ID: 21804350
oku86 thanks for that update. was working. but this i guess is more formal.
i still have the 1064 error, anyone?
0
 
LVL 4

Expert Comment

by:DrBrainiac
ID: 21805537
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
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:digarati
ID: 21805565
I now get the following error

Parse error: parse error, unexpected '=' in /home/content/site/html/beta/delete_vendor.php on line 12
0
 
LVL 1

Accepted Solution

by:
oku86 earned 2000 total points
ID: 21807999
$sql = "DELETE FROM vendor WHERE id=$id"
$sq2l = "DELETE FROM scope WHERE key=$id"

 - This should work fine - i use the same in my scripts and it deletes the record without a problem
0
 
LVL 1

Author Closing Comment

by:digarati
ID: 31467989
$sql = "DELETE FROM vendor WHERE id=$id";
$sql2 = "DELETE FROM scope WHERE `key`=$id";
what worked for me......
0
 
LVL 1

Expert Comment

by:oku86
ID: 21813656
Im glad we managed to figure it out in the end :)
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question