|  | Posted by John S. on 11/13/07 20:55 
Jerry,
 I am now using the following code in drop.php,
 
 <html>
 <head>
 <title>Dropping a Database Table</title>
 </head>
 <body>
 *****     BEGIN OF HTML PROGRAM     *****<br><br>
 <?php
 print "BEGINNING OF PHP<br>";
 $conn = mysql_connect('localhost','ximport','ximport');
 echo $conn;
 mysql_select_db('ximport',$conn);
 $sql = "DROP TABLE 'products'";
 $result = mysql_query($sql,$conn) or die(mysql_error());
 print "RESULT = ";
 echo $result;
 print "<br>END OF PHP";
 ?>
 <br><br>*****     END OF HTML PROGRAM     *****
 </body>
 </html>
 
 
 If I put products in single quotes as 'products' in the DROP command,
 I get the following output:
 
 ***** BEGIN OF HTML PROGRAM *****
 
 BEGINNING OF PHP
 Resource id #2You have an error in your SQL syntax; check the manual
 that corresponds to your MySQL server version for the right syntax to
 use near ''products'' at line 1
 
 If I put products in back ticks as `products` in the DROP command, I
 get the following output:
 
 ***** BEGIN OF HTML PROGRAM *****
 
 BEGINNING OF PHP
 Resource id #2RESULT = 1
 END OF PHP
 
 ***** END OF HTML PROGRAM *****
 
 OMG, it's gone.  I am sure I tried that several times before.  But I
 can reproduce the operation, so something must have been hung up
 somewhere.
 
 If I put products with no quotes or ticks in the DROP command, I get
 the following output:
 
 ***** BEGIN OF HTML PROGRAM *****
 
 BEGINNING OF PHP
 Resource id #2RESULT = 1
 END OF PHP
 
 ***** END OF HTML PROGRAM *****
 
 
 Seems to be better now.  Can't figure it why it did not work
 previously.  Use single quote in the $conn command, back ticks
 somewhere else, no quotes sometimes.  Is there a definite rule for
 using regular single quote, back tick (single opening quote), or no
 quote for different commands or do some work and other don't? ` for
 variable names, ' for real data, maybe?
 
 Been testing for about 30 minutes now, and there must be some time
 delay at my host because it doesn't always drop right away on 1st or
 2nd refresh of drop.php (or create fast either), at least when I look
 at the database via phpMyAdmin.  Odd I think.  But I think that that
 might have been my problem, looking for instant verification and
 instant gratification.
 
 What's the difference between resource id #2 and id #21?
 
 Thanks for your help.  I think I am right track now, but this is new
 stuff for a guy who understands the general concepts and who grew up
 with Fortran, dbase and WordStar and doesn't appreciate Windows, etc.,
 but loves the internet.
 
 Regards.
  Navigation: [Reply to this message] |