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