Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 15th, 2005, 06:16 PM
Registered User
 
Join Date: Apr 2005
Location: Boca Raton, FL, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Unknown table 'char_main' in MULTI DELETE

I'm having some trouble :( and I cannot figure out what is wrong, I am coding the comic site on Ch 9 of Beginning PHP, Apache, MySQL Web Development.

Anyways I checked all the files, this happens when I'm on charedit.php and select delete and then it goes to char_transact.php, I see the error
"Unknown table 'char_main' in MULTI DELETE" I tried looking through to see any obvious mistakes, none found, copied code over from the downloaded source code and I still get the same error, not sure what to do now :/, anyone have any other ideas?

Reply With Quote
  #2 (permalink)  
Old April 17th, 2005, 04:21 AM
Authorized User
 
Join Date: Apr 2005
Location: Spring Hill, Florida, USA.
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are you sure that the table char_main is in your configured database?

Everything is temporary, some things are just more temporary than others... except for death, that seems to be pretty permanent
Reply With Quote
  #3 (permalink)  
Old April 17th, 2005, 01:30 PM
Registered User
 
Join Date: Apr 2005
Location: Boca Raton, FL, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, char_main is in the db, I even used the sql config provided

also if it wasn't then the other section of the comic book site would not work
Reply With Quote
  #4 (permalink)  
Old April 17th, 2005, 04:18 PM
Authorized User
 
Join Date: Apr 2005
Location: Spring Hill, Florida, USA.
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are you using diffrent databases in diffrent parts of the script? The only way you will get an unknown table is if the table is unknown. I would check that you are connecting to the correct database at the time that the statment is run. Run the statment in sql and see what turns up.

Everything is temporary, some things are just more temporary than others... except for death, that seems to be pretty permanent
Reply With Quote
  #5 (permalink)  
Old April 18th, 2005, 10:44 AM
Registered User
 
Join Date: Apr 2005
Location: Boca Raton, FL, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I believe I am connecting to the correct DB, there is only one database, heres the code I believe it is erroring out on

Code:
 $sql = "DELETE FROM char_main, char_lair USING char_main m,
   char_lair l WHERE m.lair_id = l.id AND m.id = $cid";
  $result = mysql_query($sql) or die(mysql_error());


Reply With Quote
  #6 (permalink)  
Old April 18th, 2005, 03:23 PM
Authorized User
 
Join Date: Apr 2005
Location: Spring Hill, Florida, USA.
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, not a clue. Don't know SQL enough, but I'd say that that statment looks funny to me. But I can't tell you that it is wrong though. Have you tried to run that statment in sql manually just to see if the statment is structured correctly. Just replace $cid with a known value that can be deleated.

Everything is temporary, some things are just more temporary than others... except for death, that seems to be pretty permanent
Reply With Quote
  #7 (permalink)  
Old April 18th, 2005, 11:29 PM
Registered User
 
Join Date: Apr 2005
Location: Boca Raton, FL, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'll try but how could it be wrong if its the code supplied in the book, I never saw any error pages for ch 9 either

Reply With Quote
  #8 (permalink)  
Old April 19th, 2005, 05:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The book may be wrong, and no one may have told the people at Wiley about it, yet. Either that, or they've been told, and just haven't put up an erratum for it, yet: everyone is human. I don't have a copy of the book, so cannot comment on that aspect.

I CAN say that the MySQL DBM is absolutely honest in everything it says. The only reason it ever generates an "Unknown table" error, is because it's not finding a table with that name, as spelt, in the selected database. Simple as that. So there are three possiblities, and only three:
The table name is spelt wrongly in the SQL query
The table has beeen NAMED wrongly in the actual DB
You're in the wrong DB

:)
Reply With Quote
  #9 (permalink)  
Old October 13th, 2006, 05:01 AM
Registered User
 
Join Date: Oct 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I had this error and resolved it using the alias name instead of the table name.

SO FOR THE QUERY IN THIS POSTING :-

$sql = "DELETE FROM m, l USING char_main m,
   char_lair l WHERE m.lair_id = l.id AND m.id = $cid";
  $result = mysql_query($sql) or die(mysql_error());

ORIGINAL POSTER'S CODE

$sql = "DELETE FROM char_main, char_lair USING char_main m,
   char_lair l WHERE m.lair_id = l.id AND m.id = $cid";
  $result = mysql_query($sql) or die(mysql_error());

THIS POSTING is a late response (>1year) made due do it appearing in Google at position #1 for "Unknown table in MULTI DELETE".
Reply With Quote
  #10 (permalink)  
Old December 11th, 2006, 04:59 PM
Registered User
 
Join Date: Dec 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I am now reading the book and I got the same error as "uniacid".

I used the solution provided by "responder456" and it works (using the alias name of the tables in the DELETE FROM statements instead of the real names of the tables).

This topic is very old, but I still want to confirm the solution provided by "responder456", because I did a search on Google for and "Unknown table" "in MULTI DELETE" mySQL and it led me right on this site (4th result), which is very impressive because I am precisely reading this book and I got the exact same error!

Daniel Walker, the problem is not a problem of table spelling or wrong database, it really is a problem of alias naming. I don't know why the DELETE statement did this kind of error, but I suspect it is because of the MULTI DELETE part. There is a similar bug with MULTI DELETE on mysql.com. Maybe when you do a delete on multiple tables at the same time, you have to use the alias instead of the table names.

Anyway, I am not a SQL pro, but the syntax provided by "responder456" truly works for this particular type of problems, so I hope the folks reading the book and tearing hair off their head will make a good enough search on Google to fall on this page!

Good Luck with all your bugs!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi table DataGrid melvik C# 1 October 6th, 2007 04:30 PM
Ordering price when multi-currency table jwhite68 SQL Server 2000 3 June 13th, 2007 08:46 AM
"Unknown error" message when trying to open table el_oliver SQL Server 2000 2 January 4th, 2007 04:41 AM
Delete Table Teqlump Access 6 September 10th, 2004 04:25 PM
Opening unknown table names NiMot VB Databases Basics 2 July 17th, 2003 02:37 PM



All times are GMT -4. The time now is 03:52 PM.


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