RE: [PHP-DB] Stuck trying to upload and grab file name
| From: | Brad | Date: | Thu, 26 Jul 2012 00:28:43 +0000 |
| Subject: | RE: [PHP-DB] Stuck trying to upload and grab file name | ||
| References: | 1 2 3 4 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-48362@lists.php.net to get a copy of this message | ||
I am not sure I am following you sir. Can you send me a sample?
$tmp_name is incorrect and should only be used for the upload.
On a whim I tried -> ALTER TABLE
{$memberID} ADD tmp_name VARCHAR(60);
making it static and it still errored the same.
Brad
From: Roberto Carlos Garcia Luis [mailto:legnakarlos@gmail.com]
Sent: Wednesday, July 25, 2012 8:17 PM
To: Brad
Cc: Karl DeSaulniers; php-db@lists.php.net
Subject: Re: [PHP-DB] Stuck trying to upload and grab file name
The table ñame need The ñame var not tmp_name tmp_name contains / bar
El miércoles, 25 de julio de 2012, Brad escribió:
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@designdrumm.com <javascript:;> ]
Sent: Wednesday, July 25, 2012 7:18 PM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] 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@designdrumm.com]
> Sent: Wednesday, July 25, 2012 7:05 PM
> To: php-db@lists.php.net
> Subject: Re: [PHP-DB] 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 <file:///\\r\n> "
>>
>> IGNORE 1 LINES
>>
>> EOF;
>>
>> mysql_query($presql);
>>
>> mysql_query($sql);
>>
>> //var_dump($sql);
>>
>> echo '$sql';
>>
>> if(mysql_error())
>>
>> {
>>
>>