 |
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
|
|
|
|

August 25th, 2004, 07:23 PM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

August 25th, 2004, 09:19 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
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
<><
|
|

August 25th, 2004, 10:08 PM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
duh...you think i looked at the code enough to go blind? omg, thanks for proofreading.
Derek
|
|

July 29th, 2006, 06:33 AM
|
|
Registered User
|
|
Join Date: Jul 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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";
|
|

July 29th, 2006, 07:09 AM
|
|
Registered User
|
|
Join Date: Jul 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
problem sorted.
can someone tell me the difference with ` and '
particularly when using sql.
|
|

September 2nd, 2006, 12:21 PM
|
|
Registered User
|
|
Join Date: Sep 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |