INSERT INTO TABLE
| From: | Anthony Darby | Date: | Mon, 21 May 2001 08:09:32 +0000 |
| Subject: | INSERT INTO TABLE | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-7775@lists.php.net to get a copy of this message | ||
Hello,
I have a select box which grabs table names as in the first snippit of
code.
I then have an INSERT statement which loads a text file I specifiy in a
text field into the selected table .
This executes on PHP_SELF submit.
If I replace '$t' with INTO TABLE MY_TABLE_HERE, I get an insert and the
table is populated as required without a hitch.
Replace MY_TABLE_HERE with INTO TABLE '$t' and I get nothing.
Any suggestions on this one?
Thanks in advance,
Tony
--------- snip -----------------------
<select name="table">
<?
$result = mysql_list_tables ($DB);
$i = 0;
while ($i < mysql_num_rows ($result)) {
$tb_names[$i] = mysql_tablename($result, $i);
echo "<option value=" . strtoupper($tb_names[$i]) . ">" .
strtoupper($tb_names[$i]) . "</option>";
$i++;
}
?>
</select>
----snippit 2 ------------------------
$p=trim(addslashes($path));
$t=trim($table);
if(!($result=mysql_db_query($DB, "LOAD DATA INFILE '$p' INTO TABLE '$t'
FIELDS TERMINATED BY '|' LINES TERMINATED BY ';'")))