Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 25th, 2004, 07:23 PM
Registered User
 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter6 delete.php

OK in the section at the bottom of page 178 under the // generate SQL I have created the code as they say, i even tried it in mysqladmin and it worked. The debug echo prints out the query as...
<--DELETE FROM `movie` WHERE `movie_id` = '9' LIMIT 1-->
Can anyone let me know what might the cause be.
Heres the code...

$sql = "DELETE FROM `".$_GET['type']."` WHERE `".$_GET['type']."_id` = '".$_GET['id']."' LIMIT 1";

echo "<--".$sql."-->";

$result = mysql_error($sql)
    or die("Invalid Query: " . mysql_error());

Thanks in advance.
Derek

 
Old August 25th, 2004, 09:19 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

So, what's the problem? It doesn't change the database? That may be because you have $result = mysql_error($sql); instead of $result = mysql_query($sql);...

HTH,

Snib

<><
 
Old August 25th, 2004, 10:08 PM
Registered User
 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

duh...you think i looked at the code enough to go blind? omg, thanks for proofreading.

Derek
 
Old July 29th, 2006, 06:33 AM
Registered User
 
Join Date: Jul 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I get the message

Invalid Query: 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 ''' WHERE '_id' = '5' LIMIT 1' at line 1

my coding is seemingly correct (pg 178)

//generate sql
$sql =
"DELETE FROM '".$_GET['type']."'
WHERE '".$_GET['type']."_id' = ".$_GET['id']."
LIMIT 1";

 
Old July 29th, 2006, 07:09 AM
Registered User
 
Join Date: Jul 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

problem sorted.

can someone tell me the difference with ` and '
particularly when using sql.

 
Old September 2nd, 2006, 12:21 PM
Registered User
 
Join Date: Sep 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ghitar,

Go to
http://dev.mysql.com/doc/
download your desired version of the MySQL manual.

I'm using refman 5.1.
Beginning on page 577 of my manual, it explains the use of the backtick. I found it using the Index. And, you'll have all of that information right there on your computer.

TG^2






Similar Threads
Thread Thread Starter Forum Replies Last Post
php/mysql delete button and delete query dungey PHP Databases 17 April 11th, 2009 12:24 PM
How to delete folder with php tinhbanghuu PHP How-To 4 March 26th, 2008 02:59 AM
PHP unlink() will not delete file snowbydave1 PHP How-To 2 March 27th, 2007 12:14 AM
Commit.PHP and Delete.PHP in WROX's book GiFos Beginning PHP 0 January 30th, 2007 10:51 PM
How can i delete multiple row through PHP coding taha_elearner PHP Databases 1 October 28th, 2005 05:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.