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

Posted by igrosny@gmail.com on 11/13/07 16:38

On Nov 13, 4:19 am, "John S." <giga_...@yahoo.com> wrote:
> I'm relatively new at this. I can use php to create a 'products'
> table in the SQL 'ximport' database using similar code as shown below
> but with the create rather than the drop command line. However, I
> cannot use the drop command to delete the table 'products'. What is
> wrong with the following code saved in a file called drop.php
> downloaded to my host Globat and run from the Explorer 6 browser with
> the url -- drop.php:
>
> <html>
> <head>
> <title>Dropping a Database Table</title>
> </head>
> <body>
> <br>***** BEGIN OF HTML PROGRAM *****<br>
> <?php
> $conn = mysql_connect('localhost','nameximport','pwsdximport');
> echo $conn;
> mysql_select_db('ximport',$conn);
> $sql = "DROP TABLE IF EXISTS 'products'";
> $result = mysql_query($sql,$conn);
> echo $result;
> ?>
> <br>***** END OF HTML PROGRAM *****<br>
> </body>
> </html>
>
> Note the drop line ends with single quote, double qoute, semicolon.
> There is always a secret. I can't seen to figure it out. Maybe
> Globat has not implemented this feature?! Thanks for any help. It
> would be much appreciated.

Hi John,
You need to put this single quote "`". The line will look like this

$sql = "DROP TABLE IF EXISTS `products`";

Also i recomend to exceute the query with the die statement (at least
at developing enviroment)

$result = mysql_query($sql,$conn) or die(mysql_error());

Hope it helps,

Ivan

 

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

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