You are here: Re: php sql "DROP TABLE" command « PHP Programming Language « IT news, forums, messages
Re: php sql "DROP TABLE" command

Posted by Toby A Inkster on 11/13/07 17:11

John S. wrote:

> $sql = "DROP TABLE IF EXISTS 'products'";
> $result = mysql_query($sql,$conn);

Single and double quote marks have very specific meanings in SQL. You want
to wrap the table name in double quotes, not single.

DROP TABLE "products"

However, MySQL has a nasty "feature" whereby is misinterprets the meaning
of double quotes. For this reason, it's probably nest to just leave them
out:

DROP TABLE products

As the quote marks are only really needed if the table name contains
certain non-alphanumeric characters.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 7 days, 6 min.]

TrivialEncoder/0.2
http://tobyinkster.co.uk/blog/2007/08/19/trivial-encoder/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация