Re: Re: No data?

From: Date: Fri, 27 Jul 2012 15:31:58 +0000
Subject: Re: Re: No data?
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14  Groups: php.db 
Request: Send a blank email to php-db+get-48387@lists.php.net to get a copy of this message
On 7/27/2012 11:03 AM, Brad wrote:
Even though my permissions are 777 in my /tmp I am trying to send the file to a tmp directory in my webroot and if I can even get it to create the file it has the wrong name of 'Array', and then it still does not update my database. <?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){
         $target_path = "/home/nyctelecomm.com/www/mail/upload/";
         //$_FILE function, grab files
         $inFile = $_FILES["file"];
         //Get file name
         $filename = $inFile["name"];
         //strip the file extension
         $filename = preg_replace('/\.[^.]+$/','',$filename);
         var_dump($_FILES);
         //grab sessionID which is memberID
         $memberID = $_SESSION["SESS_MEMBER_ID"];
         //identify cvs, tested with MS excel in csv format
         if ($inFile["type"] == "application/octet-stream")
                 {
                 if ($inFile["error"] > 0)
                         {
                         echo "Return Code: " . $inFile['error'] . "<br />";
                 }
                 else
                         {
                         dbConnect();
                         //move_uploaded_file($_FILES["file"],$target_path);
                         move_uploaded_file($inFile["file"]["tmp_name"],
$target_path .'/'.$inFile);
                         //chmod ($filename['file'], 0777);
                         mysql_select_db('mailList') or die(mysql_error());
                         //assign temporary name to variable
                         //for insert since tmp_file is the real file
                         //$tmp_name =  $inFile["file"];
                         $presql = "CREATE TABLE IF NOT EXISTS {$memberID}
(id MEDIUMINT AUTO_INCREMENT PRIMARY KEY UNIQUE)";
                         $midsql = "ALTER TABLE {$memberID} ADD
{$filename} VARCHAR(60)";
                         $sql = <<<EOF
                         LOAD DATA LOCAL INFILE '{$inFile}'
                         INTO TABLE {$memberID}
                         FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY
'\\''
                         LINES TERMINATED BY "\\r\\n
                         IGNORE 1 LINES ($filename)"
EOF;
                         var_dump($sql);
                         echo '$sql';
                         mysql_query($presql) or die(mysql_error());
                         mysql_query($midsql) or die(mysql_error());
                         mysql_query($sql) or die(mysql_error());
                         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(); ?> **************************************************************************** * array(1) { ["file"]=> array(5) { ["name"]=> string(13) "testBook1.csv" ["type"]=> string(24) "application/octet-stream" ["tmp_name"]=> string(14) "/tmp/phpZVJWhW" ["error"]=> int(0) ["size"]=> int(102) } } array(1) { ["file"]=> array(5) { ["name"]=> string(13) "testBook1.csv" ["type"]=> string(24) "application/octet-stream" ["tmp_name"]=> string(14) "/tmp/phpZVJWhW" ["error"]=> int(0) ["size"]=> int(102) } } Notice: Undefined index: file in /home/nyctelecomm.com/www/mail/import.php on line 29 string(169) " LOAD DATA LOCAL INFILE 'Array' INTO TABLE 3 FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY "\r\n IGNORE 1 LINES (testBook1)"" $sqlFile 'Array' not found (Errcode: 2) -----Original Message----- From: Tamara Temple [mailto:tamouse@gmail.com] Sent: Friday, July 27, 2012 10:46 AM To: Brad Cc: 'tamouse mailing lists'; php-db@lists.php.net Subject: Re: [PHP-DB] Re: No data? Brad <nyctelecomm@gmail.com> wrote:
Wow, this is unbeileivable. Your test script fails with the attached csv
where column a in blank too! No, with your attached file, it works: array(2) { [0]=> string(15) "brads@yahoo.com" [1]=> string(1) "1" } array(2) { [0]=> string(15) "brads@yahoo.com" [1]=> string(1) "2" } array(2) { [0]=> string(15) "brads@yahoo.com" [1]=> string(1) "3" } array(2) { [0]=> string(15) "brads@yahoo.com" [1]=> string(1) "4" } array(2) { [0]=> string(15) "brads@yahoo.com" [1]=> string(1) "5" } array(2) { [0]=> string(15) "brads@yahoo.com" [1]=> string(1) "6" } You seem to be very stubborn in your attempts to handle this problem. All the suggestions we have provided you seem to be ignoring. Dont' understand your mentality and I surely hope you are not exhausting your employer's resources on this effort.
Once again - upload the file and move it and name it. Then never reference $_FILES again. In particular - in your latest posting here you appear to have misused the $infile var in your DATA LOAD statement. See how confusing you make this for yourself? Leave me off any future emails. I have lost interest. :(

« previous php.db (#48387) next »