Switching it to -> ALTER TABLE `{$memberID}` ADD {$tmp_name} VARCHAR(60); produces the same error. For the record $tmp_name is just gibberish and should not be the final column name. Brad -----Original Message----- From: Karl DeSaulniers [mailto:karl@xxxxxxxxxxxxxxx] Sent: Wednesday, July 25, 2012 7:18 PM To: php-db@xxxxxxxxxxxxx Subject: Re: Re: Stuck trying to upload and grab file name On Jul 25, 2012, at 6:11 PM, Brad wrote: > I am only uploading the temporary file. The filename is acquired via > -> $file = $_FILES["file"]; and that is what is included in the naming > of the column. > > > > -----Original Message----- > From: Karl DeSaulniers [mailto:karl@xxxxxxxxxxxxxxx] > Sent: Wednesday, July 25, 2012 7:05 PM > To: php-db@xxxxxxxxxxxxx > Subject: Re: Re: Stuck trying to upload and grab file name > > On Jul 25, 2012, at 5:49 PM, Brad wrote: > >> I revamped my logic, proved the SQL works in a client the way I want >> and once again, I am hitting the same mysql brick wall. >> >> >> >> <?php >> >> var_dump($_FILES); >> >> //db connection >> >> require 'dbConnect.php'; >> >> //session file >> >> require_once('../auth.php'); >> >> function uploadList(){ >> >> $file = $_FILES["file"]; >> >> $memberID = $_SESSION["SESS_MEMBER_ID"]; >> >> if ($file["type"] == "text/plain") >> >> { >> >> if ($file["error"] > 0) >> >> { >> >> echo "Return Code: " . $file['error'] . "<br / >>> "; >> >> } >> >> else >> >> { >> >> dbConnect(); >> >> mysql_select_db('mailList') or >> die(mysql_error()); >> >> $tmp_name = $file["tmp_name"]; >> >> $presql = "CREATE TABLE IF NOT EXISTS >> `{$memberID}` (id MEDIUMINT AUTO_INCREMENT PRIMARY KEY UNIQUE)"; >> >> $sql = <<<EOF >> >> LOAD DATA LOCAL INFILE '{$tmp_name}' >> >> ALTER TABLE `{$memberID}` ADD {$file} >> VARCHAR(60); >> >> FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY >> '\\'' >> >> LINES TERMINATED BY "\\r\\n" >> >> IGNORE 1 LINES >> >> EOF; >> >> mysql_query($presql); >> >> mysql_query($sql); >> >> //var_dump($sql); >> >> echo '$sql'; >> >> if(mysql_error()) >> >> { >> >> echo(mysql_error()); >> >> } >> >> else >> >> { >> >> print('Import of campaign emails >> sucessfull into mysql table.'); >> >> } >> >> } >> >> } >> >> else >> >> { >> >> print('Invalid file type. Please make sure it is a text >> file.'); >> >> } >> >> } >> >> >> >> //var_dump($_FILES); >> >> uploadList(); >> >> ?> >> >> >> >> ********************************error************************* >> >> >> >> array(1) { ["file"]=> array(5) { ["name"]=> string(14) >> "emailsTest.txt" >> ["type"]=> string(10) "text/plain" ["tmp_name"]=> string(14) >> "/tmp/phpBKCv3n" ["error"]=> int(0) ["size"]=> int(61) } } $sqlYou >> have an error in your SQL syntax; check the manual that corresponds >> to your MySQL server version for the right syntax to use near 'ALTER >> TABLE `3` ADD Array VARCHAR(60); FIELDS TERMINATED BY ',' OPTIONALLY >> EN' at line 2 >> >> >> >> ********************proof it's supposed to work**************** >> >> >> >> >> >> mysql> CREATE TABLE IF NOT EXISTS `215` (id MEDIUMINT AUTO_INCREMENT >> PRIMARY >> KEY UNIQUE); >> >> Query OK, 0 rows affected (0.00 sec) >> >> >> >> mysql> ALTER TABLE `215` ADD emailList VARCHAR(40); >> >> Query OK, 0 rows affected (0.00 sec) >> >> Records: 0 Duplicates: 0 Warnings: 0 >> >> >> > > > Just currious and for my own edification. > Why are you trying to store the temp name in your database? > You should move and rename the file and then store that name in your > database. > If I understand temp_name, that name dissapears after done processing. > > Am I correct everyone? > > Shouldn't he move the file first and rename then store? > > and do you store the path in the database or just the name? > Because the temp_name var has directory slashes in it and if those are > not escaped it wont work. > > Best, > Karl DeSaulniers > Design Drumm > http://designdrumm.com > > > -- > PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: > http://www.php.net/unsub.php > > > -- > PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: > http://www.php.net/unsub.php > Try using that to store in the database and dont use it for the column name. use `mail_file` or something like that for the column name. Karl DeSaulniers Design Drumm http://designdrumm.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php