Re: [PHP-DB] Stuck trying to upload and grab file name
Brad nyctelec...@gmail.com wrote: Here is where everything stands.. L http://pastie.org/4317155 I feel strange bottom posting, somehow, BUT THAT'S THE RULE You have never actually shown what your SQL statement is, because: line 33: echo '$sql'; This will NOT interpolate the sql string. This is why you keep getting: line 57: array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/phpcLtE6W [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 ''\' LINES TERMINATED BY \r\n IGNORE 1 LINES' at line 3 See where it says $sqlYou have after your vardump of $_FILES? Change: Line 33 to: echo $sql.PHP_EOL; then give it a go. (The actual source of your problem is elsewhere, but I'll let you go from there.) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Stuck trying to upload and grab file name
On Wed, Jul 25, 2012 at 12:21 PM, Tamara Temple tamouse.li...@tamaratemple.com wrote: Brad nyctelec...@gmail.com wrote: Here is where everything stands.. L http://pastie.org/4317155 I feel strange bottom posting, somehow, BUT THAT'S THE RULE It makes each individual message readable in a human readable order. That's why. You have never actually shown what your SQL statement is, because: line 33: echo '$sql'; This will NOT interpolate the sql string. This is why you keep getting: line 57: array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/phpcLtE6W [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 ''\' LINES TERMINATED BY \r\n IGNORE 1 LINES' at line 3 See where it says $sqlYou have after your vardump of $_FILES? Change: Line 33 to: echo $sql.PHP_EOL; then give it a go. A quick guess, you probably need double escapes at OPTIONALLY ENCLOSED BY '\\', like OPTIONALLY ENCLOSED BY '' - Matijn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Stuck trying to upload and grab file name
On Jul 25, 2012, at 5:21 AM, Tamara Temple wrote: Brad nyctelec...@gmail.com wrote: Here is where everything stands.. L http://pastie.org/4317155 I feel strange bottom posting, somehow, BUT THAT'S THE RULE You have never actually shown what your SQL statement is, because: line 33: echo '$sql'; This will NOT interpolate the sql string. This is why you keep getting: line 57: array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/phpcLtE6W [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 ''\' LINES TERMINATED BY \r\n IGNORE 1 LINES' at line 3 See where it says $sqlYou have after your vardump of $_FILES? Change: Line 33 to: echo $sql.PHP_EOL; then give it a go. (The actual source of your problem is elsewhere, but I'll let you go from there.) -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php $sql = BLAH BLAH BLAH var='.mysql_real_escape_string($var).' LINES TERMINATED BY '\r\n' IGNORE 1 LINES; Strings for SQL are wrapped in single quotes and dont escape your single quotes, the php $sql string is wrapped in double quotes. HTH, 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
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:k...@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:k...@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 IGNORE 1 LINES EOF; mysql_query($presql); mysql_query($sql); //var_dump($sql); echo '$sql'; if(mysql_error()) {
RE: [PHP-DB] Stuck trying to upload and grab file name
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:legnakar...@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:k...@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:k...@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()) {
[PHP-DB] Stuck trying to upload and grab file name
I am making a function that uploads a txt file in csv format and the grabs uploaded file name and the memberID from the sessions login and names the new table memberID_filename. The program error on line 24 @ 'name'. I have tried '{$_FILES[file][name]}' '{$_FILES[file]['name']}' '{$_FILES['file']['name']}' {$_FILES[file][name]} {$_FILES['file']['name']} $_FILES[file][name]$_FILES[file]['name'] $_FILES['file']['name'] '$_FILES[file][name]' '$_FILES['file']['name']' and '$_FILES[0]['name']' code* ?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){ //var_dump($_FILES); if ($_FILES[file][type] == text/plain) { if ($_FILES[file][error] 0) { echo Return Code: . $_FILES['file']['error'] . br /; } else { dbConnect(); mysql_select_db('mailList') or die(mysql_error()); //$file='' $file = $_FILES['file']['name']; //$presql = CREATE TABLE IF NOT EXISTS (`$_SESSION[SESS_MEMBER_ID]_$file`); $presql = CREATE TABLE IF NOT EXISTS `$_SESSION[SESS_MEMBER_ID]_$file`; $sql = EOF LOAD DATA LOCAL INFILE '{$_FILES['file']['name']}' INTO TABLE `$_SESSION[SESS_MEMBER_ID]_$file` 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/phpmycbhK [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 ''\' LINES TERMINATED BY \r\n IGNORE 1 LINES' at line 3 SQL query works when removed from the php mysql LOAD DATA LOCAL INFILE '/home/nyctelecomm.com/www/mail/emailtist.txt' - INTO TABLE `mailTest` - FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\\' - LINES TERMINATED BY \\r\\n - IGNORE 1 LINES; Query OK, 0 rows affected (0.00 sec) Records: 0 Deleted: 0 Skipped: 0 Warnings: 0 ***show create* mysql SHOW CREATE TABLE mailTest\G *** 1. row *** Table: mailTest Create Table: CREATE TABLE `mailTest` ( `temp` tinyint(4) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 1 row in set (0.00 sec) *sample data* k2jthep...@hotmail.com annama...@gmail.com ken_cas...@yahoo.com jmakse...@gmail.com janegre...@hotmail.com mitcha...@yahoo.com klj...@hotmail.com var_dump($_FILES[file]) at line 8 array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/php98AolN [error]= int(0) [size]= int(61) } } array(5) { [name]= string(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/php98AolN [error]= int(0) [size]= int(61) }
Re: [PHP-DB] Stuck trying to upload and grab file name
You need to use te tmp_name ... The plain text file is in path indicated by The string... Regards, El martes, 24 de julio de 2012, Brad escribió: I am making a function that uploads a txt file in csv format and the grabs uploaded file name and the memberID from the sessions login and names the new table memberID_filename. The program error on line 24 @ 'name'. I have tried '{$_FILES[file][name]}' '{$_FILES[file]['name']}' '{$_FILES['file']['name']}' {$_FILES[file][name]} {$_FILES['file']['name']} $_FILES[file][name]$_FILES[file]['name'] $_FILES['file']['name'] '$_FILES[file][name]' '$_FILES['file']['name']' and '$_FILES[0]['name']' code* ?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){ //var_dump($_FILES); if ($_FILES[file][type] == text/plain) { if ($_FILES[file][error] 0) { echo Return Code: . $_FILES['file']['error'] . br /; } else { dbConnect(); mysql_select_db('mailList') or die(mysql_error()); //$file='' $file = $_FILES['file']['name']; //$presql = CREATE TABLE IF NOT EXISTS (`$_SESSION[SESS_MEMBER_ID]_$file`); $presql = CREATE TABLE IF NOT EXISTS `$_SESSION[SESS_MEMBER_ID]_$file`; $sql = EOF LOAD DATA LOCAL INFILE '{$_FILES['file']['name']}' INTO TABLE `$_SESSION[SESS_MEMBER_ID]_$file` 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/phpmycbhK [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 ''\' LINES TERMINATED BY \r\n IGNORE 1 LINES' at line 3 SQL query works when removed from the php mysql LOAD DATA LOCAL INFILE '/home/ nyctelecomm.com/www/mail/emailtist.txt' - INTO TABLE `mailTest` - FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\\' - LINES TERMINATED BY \\r\\n - IGNORE 1 LINES; Query OK, 0 rows affected (0.00 sec) Records: 0 Deleted: 0 Skipped: 0 Warnings: 0 ***show create* mysql SHOW CREATE TABLE mailTest\G *** 1. row *** Table: mailTest Create Table: CREATE TABLE `mailTest` ( `temp` tinyint(4) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 1 row in set (0.00 sec) *sample data* k2jthep...@hotmail.com javascript:; annama...@gmail.com javascript:; ken_cas...@yahoo.com javascript:; jmakse...@gmail.com javascript:; janegre...@hotmail.com javascript:; mitcha...@yahoo.com javascript:; klj...@hotmail.com javascript:; var_dump($_FILES[file]) at line 8 array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/php98AolN [error]= int(0) [size]= int(61) } } array(5) { [name]= string(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/php98AolN [error]= int(0) [size]= int(61) }
Re: [PHP-DB] Stuck trying to upload and grab file name
Pelase, print The SQL var and show here The result. El martes, 24 de julio de 2012, Roberto Carlos Garcia Luis escribió: You need to use te tmp_name ... The plain text file is in path indicated by The string... Regards, El martes, 24 de julio de 2012, Brad escribió: I am making a function that uploads a txt file in csv format and the grabs uploaded file name and the memberID from the sessions login and names the new table memberID_filename. The program error on line 24 @ 'name'. I have tried '{$_FILES[file][name]}' '{$_FILES[file]['name']}' '{$_FILES['file']['name']}' {$_FILES[file][name]} {$_FILES['file']['name']} $_FILES[file][name]$_FILES[file]['name'] $_FILES['file']['name'] '$_FILES[file][name]' '$_FILES['file']['name']' and '$_FILES[0]['name']' code* ?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){ //var_dump($_FILES); if ($_FILES[file][type] == text/plain) { if ($_FILES[file][error] 0) { echo Return Code: . $_FILES['file']['error'] . br /; } else { dbConnect(); mysql_select_db('mailList') or die(mysql_error()); //$file='' $file = $_FILES['file']['name']; //$presql = CREATE TABLE IF NOT EXISTS (`$_SESSION[SESS_MEMBER_ID]_$file`); $presql = CREATE TABLE IF NOT EXISTS `$_SESSION[SESS_MEMBER_ID]_$file`; $sql = EOF LOAD DATA LOCAL INFILE '{$_FILES['file']['name']}' INTO TABLE `$_SESSION[SESS_MEMBER_ID]_$file` 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/phpmycbhK [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 ''\' LINES TERMINATED BY \r\n IGNORE 1 LINES' at line 3 SQL query works when removed from the php mysql LOAD DATA LOCAL INFILE '/home/ nyctelecomm.com/www/mail/emailtist.txt' - INTO TABLE `mailTest` - FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\\' - LINES TERMINATED BY \\r\\n - IGNORE 1 LINES; Query OK, 0 rows affected (0.00 sec) Records: 0 Deleted: 0 Skipped: 0 Warnings: 0 ***show create* mysql SHOW CREATE TABLE mailTest\G *** 1. row *** Table: mailTest Cre
RE: [PHP-DB] Stuck trying to upload and grab file name
The tmp_file is just gibberish. I truly do not want that as the table name. From: Roberto Carlos Garcia Luis [mailto:legnakar...@gmail.com] Sent: Tuesday, July 24, 2012 4:26 AM To: Brad Cc: php-db@lists.php.net Subject: Re: [PHP-DB] Stuck trying to upload and grab file name You need to use te tmp_name ... The plain text file is in path indicated by The string... Regards, El martes, 24 de julio de 2012, Brad escribió: I am making a function that uploads a txt file in csv format and the grabs uploaded file name and the memberID from the sessions login and names the new table memberID_filename. The program error on line 24 @ 'name'. I have tried '{$_FILES[file][name]}' '{$_FILES[file]['name']}' '{$_FILES['file']['name']}' {$_FILES[file][name]} {$_FILES['file']['name']} $_FILES[file][name]$_FILES[file]['name'] $_FILES['file']['name'] '$_FILES[file][name]' '$_FILES['file']['name']' and '$_FILES[0]['name']' code* ?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){ //var_dump($_FILES); if ($_FILES[file][type] == text/plain) { if ($_FILES[file][error] 0) { echo Return Code: . $_FILES['file']['error'] . br /; } else { dbConnect(); mysql_select_db('mailList') or die(mysql_error()); //$file='' $file = $_FILES['file']['name']; //$presql = CREATE TABLE IF NOT EXISTS (`$_SESSION[SESS_MEMBER_ID]_$file`); $presql = CREATE TABLE IF NOT EXISTS `$_SESSION[SESS_MEMBER_ID]_$file`; $sql = EOF LOAD DATA LOCAL INFILE '{$_FILES['file']['name']}' INTO TABLE `$_SESSION[SESS_MEMBER_ID]_$file` 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()) { 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/phpmycbhK [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 ''\' LINES TERMINATED BY \r\n IGNORE 1 LINES' at line 3 SQL query works when removed from the php mysql LOAD DATA LOCAL INFILE '/home/nyctelecomm.com/www/mail/emailtist.txt' - INTO TABLE `mailTest` - FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\\' - LINES TERMINATED BY \\r\\n file:///\\r\n - IGNORE 1 LINES; Query OK, 0 rows affected (0.00 sec) Records: 0 Deleted: 0 Skipped: 0 Warnings: 0 ***show create* mysql SHOW CREATE TABLE mailTest\G *** 1. row *** Table: mailTest Create Table: CREATE TABLE `mailTest` ( `temp` tinyint(4) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8 1 row in set (0.00 sec) *sample data* k2jthep...@hotmail.com javascript:; annama...@gmail.com javascript:; ken_cas...@yahoo.com javascript:; jmakse...@gmail.com javascript:; janegre...@hotmail.com javascript:; mitcha...@yahoo.com javascript:; klj...@hotmail.com javascript:; var_dump($_FILES[file]) at line 8 array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/php98AolN [error]= int(0) [size]= int(61) } } array(5) { [name]= string(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/php98AolN [error]= int(0) [size]= int(61) }
RE: [PHP-DB] Stuck trying to upload and grab file name
array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/php98AolN [error]= int(0) [size]= int(61) } } array(5) { [name]= string(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/php98AolN [error]= int(0) [size]= int(61) } From: Roberto Carlos Garcia Luis [mailto:legnakar...@gmail.com] Sent: Tuesday, July 24, 2012 4:30 AM To: Brad Cc: php-db@lists.php.net Subject: Re: [PHP-DB] Stuck trying to upload and grab file name Pelase, print The SQL var and show here The result. El martes, 24 de julio de 2012, Roberto Carlos Garcia Luis escribió: You need to use te tmp_name ... The plain text file is in path indicated by The string... Regards, El martes, 24 de julio de 2012, Brad escribió: I am making a function that uploads a txt file in csv format and the grabs uploaded file name and the memberID from the sessions login and names the new table memberID_filename. The program error on line 24 @ 'name'. I have tried '{$_FILES[file][name]}' '{$_FILES[file]['name']}' '{$_FILES['file']['name']}' {$_FILES[file][name]} {$_FILES['file']['name']} $_FILES[file][name]$_FILES[file]['name'] $_FILES['file']['name'] '$_FILES[file][name]' '$_FILES['file']['name']' and '$_FILES[0]['name']' code* ?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){ //var_dump($_FILES); if ($_FILES[file][type] == text/plain) { if ($_FILES[file][error] 0) { echo Return Code: . $_FILES['file']['error'] . br /; } else { dbConnect(); mysql_select_db('mailList') or die(mysql_error()); //$file='' $file = $_FILES['file']['name']; //$presql = CREATE TABLE IF NOT EXISTS (`$_SESSION[SESS_MEMBER_ID]_$file`); $presql = CREATE TABLE IF NOT EXISTS `$_SESSION[SESS_MEMBER_ID]_$file`; $sql = EOF LOAD DATA LOCAL INFILE '{$_FILES['file']['name']}' INTO TABLE `$_SESSION[SESS_MEMBER_ID]_$file` 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()) { 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/phpmycbhK [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 ''\' LINES TERMINATED BY \r\n IGNORE 1 LINES' at line 3 SQL query works when removed from the php mysql LOAD DATA LOCAL INFILE '/home/nyctelecomm.com/www/mail/emailtist.txt' - INTO TABLE `mailTest` - FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\\' - LINES TERMINATED BY \\r\\n file:///\\r\n - IGNORE 1 LINES; Query OK, 0 rows affected (0.00 sec) Records: 0 Deleted: 0 Skipped: 0 Warnings: 0 ***show create* mysql SHOW CREATE TABLE mailTest\G *** 1. row *** Table: mailTest Cre
Re: [PHP-DB] Stuck trying to upload and grab file name
In the LOAD DATA LOCAL INFILE '{$_FILES['file']['name']}' You need use The tmp_name to load The file contents. And The SQL var result as a string diferent of The SQL that you insert in console El martes, 24 de julio de 2012, Brad escribió: The tmp_file is just gibberish. I ‘truly’ do not want that as the table name. ** ** ** ** ** ** ** ** *From:* Roberto Carlos Garcia Luis [mailto:legnakar...@gmail.comjavascript:_e({}, 'cvml', 'legnakar...@gmail.com');] *Sent:* Tuesday, July 24, 2012 4:26 AM *To:* Brad *Cc:* php-db@lists.php.net javascript:_e({}, 'cvml', 'php-db@lists.php.net'); *Subject:* Re: [PHP-DB] Stuck trying to upload and grab file name ** ** You need to use te tmp_name ... The plain text file is in path indicated by The string... ** ** Regards, El martes, 24 de julio de 2012, Brad escribió: I am making a function that uploads a txt file in csv format and the grabs uploaded file name and the memberID from the sessions login and names the new table memberID_filename. The program error on line 24 @ 'name'. I have tried '{$_FILES[file][name]}' '{$_FILES[file]['name']}' '{$_FILES['file']['name']}' {$_FILES[file][name]} {$_FILES['file']['name']} $_FILES[file][name]$_FILES[file]['name'] $_FILES['file']['name'] '$_FILES[file][name]' '$_FILES['file']['name']' and '$_FILES[0]['name']' code* ?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){ //var_dump($_FILES); if ($_FILES[file][type] == text/plain) { if ($_FILES[file][error] 0) { echo Return Code: . $_FILES['file']['error'] . br /; } else { dbConnect(); mysql_select_db('mailList') or die(mysql_error()); //$file='' $file = $_FILES['file']['name']; //$presql = CREATE TABLE IF NOT EXISTS (`$_SESSION[SESS_MEMBER_ID]_$file`); $presql = CREATE TABLE IF NOT EXISTS `$_SESSION[SESS_MEMBER_ID]_$file`; $sql = EOF LOAD DATA LOCAL INFILE '{$_FILES['file']['name']}' INTO TABLE `$_SESSION[SESS_MEMBER_ID]_$file` 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/phpmycbhK [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 ''\' LINES TERMINATED BY \r\n IGNORE 1 LINES' at line 3 SQL query works when removed from the php mysql LOAD DATA LOCAL INFILE '/home/ nyctelecomm.com/www/mail/emailtist.txt' - INTO TABLE `mailTest` - FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\\' - LINES TERMINATED BY \\r\\n - IGNORE 1 LINES; Query OK, 0 rows affected (0.00 sec) Records: 0 Deleted: 0 Skipped: 0 Warnings: 0 ***show create* mysql SHOW CREA
RE: [PHP-DB] Stuck trying to upload and grab file name
?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){ //var_dump($_FILES['file']); if ($_FILES[file][type] == text/plain) { if ($_FILES[file][error] 0) { echo Return Code: . $_FILES['file']['error'] . br /; } else { dbConnect(); mysql_select_db('mailList') or die(mysql_error()); //$file='' $file = $_FILES['tmp_name']; //$presql = CREATE TABLE IF NOT EXISTS (`$_SESSION[SESS_MEMBER_ID]_$file`); $presql = CREATE TABLE IF NOT EXISTS `$_SESSION[SESS_MEMBER_ID]_$file`; $sql = EOF LOAD DATA LOCAL INFILE '{$_FILES['tmp_name']}' INTO TABLE `$_SESSION[SESS_MEMBER_ID]_$file` 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(); ? array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/phpq8pi44 [error]= int(0) [size]= int(61) } } Notice: Undefined index: tmp_name in /home/nyctelecomm.com/www/mail/import.php on line 20 Notice: Undefined index: tmp_name in /home/nyctelecomm.com/www/mail/import.php on line 24 $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 ''\' LINES TERMINATED BY \r\n IGNORE 1 LINES' at line 3 From: Roberto Carlos Garcia Luis [mailto:legnakar...@gmail.com] Sent: Tuesday, July 24, 2012 5:12 AM To: Brad Cc: php-db@lists.php.net Subject: Re: [PHP-DB] Stuck trying to upload and grab file name In the LOAD DATA LOCAL INFILE '{$_FILES['file']['name']}' You need use The tmp_name to load The file contents. And The SQL var result as a string diferent of The SQL that you insert in console El martes, 24 de julio de 2012, Brad escribió: The tmp_file is just gibberish. I truly do not want that as the table name. From: Roberto Carlos Garcia Luis [mailto:legnakar...@gmail.com javascript:_e(%7b%7d,%20'cvml',%20'legnakar...@gmail.com'); ] Sent: Tuesday, July 24, 2012 4:26 AM To: Brad Cc: php-db@lists.php.net javascript:_e(%7b%7d,%20'cvml',%20'php-db@lists.php.net'); Subject: Re: [PHP-DB] Stuck trying to upload and grab file name You need to use te tmp_name ... The plain text file is in path indicated by The string... Regards, El martes, 24 de julio de 2012, Brad escribió: I am making a function that uploads a txt file in csv format and the grabs uploaded file name and the memberID from the sessions login and names the new table memberID_filename. The program error on line 24 @ 'name'. I have tried '{$_FILES[file][name]}' '{$_FILES[file]['name']}' '{$_FILES['file']['name']}' {$_FILES[file][name]} {$_FILES['file']['name']} $_FILES[file][name]$_FILES[file]['name'] $_FILES['file']['name'] '$_FILES[file][name]' '$_FILES['file']['name']' and '$_FILES[0]['name']' code* ?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){ //var_dump($_FILES); if ($_FILES[file][type] == text/plain) { if ($_FILES[file][error] 0) { echo Return Code: . $_FILES['file']['error'] . br /; } else { dbConnect(); mysql_select_db('mailList') or die(mysql_error()); //$file='' $file = $_FILES['file']['name']; //$presql = CREATE TABLE IF NOT EXISTS (`$_SESSION[SESS_MEMBER_ID]_$file`); $presql = CREATE TABLE IF NOT EXISTS `$_SESSION[SESS_MEMBER_ID]_$file`; $sql = EOF
Re: [PHP-DB] Stuck trying to upload and grab file name
Use $_FILES[file][tmp_name] El martes, 24 de julio de 2012, Brad escribió: ?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){ //var_dump($_FILES['file']); if ($_FILES[file][type] == text/plain) { if ($_FILES[file][error] 0) { echo Return Code: . $_FILES['file']['error'] . br /; } else { dbConnect(); mysql_select_db('mailList') or die(mysql_error()); //$file='' $file = $_FILES['tmp_name']; //$presql = CREATE TABLE IF NOT EXISTS (`$_SESSION[SESS_MEMBER_ID]_$file`); $presql = CREATE TABLE IF NOT EXISTS `$_SESSION[SESS_MEMBER_ID]_$file`; $sql = EOF LOAD DATA LOCAL INFILE '{$_FILES['tmp_name']}' INTO TABLE `$_SESSION[SESS_MEMBER_ID]_$file` 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(); ? ** ** ** ** array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/phpq8pi44 [error]= int(0) [size]= int(61) } } *Notice*: Undefined index: tmp_name in */home/ nyctelecomm.com/www/mail/import.php* on line *20* *Notice*: Undefined index: tmp_name in */home/ nyctelecomm.com/www/mail/import.php* on line *24* $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 ''\' LINES TERMINATED BY \r\n IGNORE 1 LINES' at line 3 ** ** *From:* Roberto Carlos Garcia Luis [mailto:legnakar...@gmail.comjavascript:_e({}, 'cvml', 'legnakar...@gmail.com');] *Sent:* Tuesday, July 24, 2012 5:12 AM *To:* Brad *Cc:* php-db@lists.php.net javascript:_e({}, 'cvml', 'php-db@lists.php.net'); *Subject:* Re: [PHP-DB] Stuck trying to upload and grab file name ** ** In the LOAD DATA LOCAL INFILE '{$_FILES['file']['name']}' You need use The tmp_name to load The file contents. And The SQL var result as a string diferent of The SQL that you insert in console ** ** El martes, 24 de julio de 2012, Brad escribió: The tmp_file is just gibberish. I ‘truly’ do not want that as the table name. *From:* Roberto Carlos Garcia Luis [mailto:legnakar...@gmail.com] *Sent:* Tuesday, July 24, 2012 4:26 AM *To:* Brad *Cc:* php-db@lists.php.net *Subject:* Re: [PHP-DB] Stuck trying to upload and grab file name You need to use te tmp_name ... The plain text file is in path indicated by The string... Regards, El martes, 24 de julio de 2012, Brad escribió: I am making a function that uploads a txt file in csv format and the grabs uploaded file name and the memberID from the sessions login and names the new table memberID_filename. The program error on line 24 @ 'name'. I have tried '{$_FILES[file][name]}' '{$_FILES[file]['name']}' '{$_FILES['file']['name']}' {$_FILES[file][name]} {$_FILES['file']['name']} $_FILES[file][name]$_FILES[file]['name'] $_FILES['file']['name'] '$_FILES[file][name]' '$_FILES['file']['name']' and '$_FILES[0]['name']' code* ?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){ //var_dump($_FILES); if ($_FILES[file][type] == text/plain) { if ($_FILES[file][error] 0) { echo Return Code: . $_FILES['file']['error'] . br
RE: [PHP-DB] Stuck trying to upload and grab file name
array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/php8Tx8es [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 ''\' LINES TERMINATED BY \r\n IGNORE 1 LINES' at line 3 Brad From: Roberto Carlos Garcia Luis [mailto:legnakar...@gmail.com] Sent: Tuesday, July 24, 2012 5:23 AM To: Brad Cc: php-db@lists.php.net Subject: Re: [PHP-DB] Stuck trying to upload and grab file name Use $_FILES[file][tmp_name] El martes, 24 de julio de 2012, Brad escribió: ?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){ //var_dump($_FILES['file']); if ($_FILES[file][type] == text/plain) { if ($_FILES[file][error] 0) { echo Return Code: . $_FILES['file']['error'] . br /; } else { dbConnect(); mysql_select_db('mailList') or die(mysql_error()); //$file='' $file = $_FILES['tmp_name']; //$presql = CREATE TABLE IF NOT EXISTS (`$_SESSION[SESS_MEMBER_ID]_$file`); $presql = CREATE TABLE IF NOT EXISTS `$_SESSION[SESS_MEMBER_ID]_$file`; $sql = EOF LOAD DATA LOCAL INFILE '{$_FILES['tmp_name']}' INTO TABLE `$_SESSION[SESS_MEMBER_ID]_$file` 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()) { 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(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/phpq8pi44 [error]= int(0) [size]= int(61) } } Notice: Undefined index: tmp_name in /home/nyctelecomm.com/www/mail/import.php on line 20 Notice: Undefined index: tmp_name in /home/nyctelecomm.com/www/mail/import.php on line 24 $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 ''\' LINES TERMINATED BY \r\n IGNORE 1 LINES' at line 3 From: Roberto Carlos Garcia Luis [mailto:legnakar...@gmail.com javascript:_e(%7b%7d,%20'cvml',%20'legnakar...@gmail.com'); ] Sent: Tuesday, July 24, 2012 5:12 AM To: Brad Cc: php-db@lists.php.net javascript:_e(%7b%7d,%20'cvml',%20'php-db@lists.php.net'); Subject: Re: [PHP-DB] Stuck trying to upload and grab file name In the LOAD DATA LOCAL INFILE '{$_FILES['file']['name']}' You need use The tmp_name to load The file contents. And The SQL var result as a string diferent of The SQL that you insert in console El martes, 24 de julio de 2012, Brad escribió: The tmp_file is just gibberish. I truly do not want that as the table name. From: Roberto Carlos Garcia Luis [mailto:legnakar...@gmail.com] Sent: Tuesday, July 24, 2012 4:26 AM To: Brad Cc: php-db@lists.php.net Subject: Re: [PHP-DB] Stuck trying to upload and grab file name You need to use te tmp_name ... The plain text file is in path indicated by The string... Regards, El martes, 24 de julio de 2012, Brad escribió: I am making a function that uploads a txt file in csv format and the grabs uploaded file name and the memberID from the sessions login and names the new table memberID_filename. The program error on line 24 @ 'name'. I have tried '{$_FILES[file][name]}' '{$_FILES[file]['name']}' '{$_FILES['file']['name']}' {$_FILES[file][name]} {$_FILES['file']['name']} $_FILES[file][name]$_FILES[file]['name'] $_FILES['file']['name'] '$_FILES[file][name]' '$_FILES['file']['name']' and '$_FILES[0]['name']' code* ?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){ //var_dump($_FILES); if ($_FILES[file][type] == text/plain
RE: [PHP-DB] Stuck trying to upload and grab file name
Here is where everything stands.. L http://pastie.org/4317155 From: Roberto Carlos Garcia Luis [mailto:legnakar...@gmail.com] Sent: Tuesday, July 24, 2012 5:23 AM To: Brad Cc: php-db@lists.php.net Subject: Re: [PHP-DB] Stuck trying to upload and grab file name Use $_FILES[file][tmp_name] El martes, 24 de julio de 2012, Brad escribió: ?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){ //var_dump($_FILES['file']); if ($_FILES[file][type] == text/plain) { if ($_FILES[file][error] 0) { echo Return Code: . $_FILES['file']['error'] . br /; } else { dbConnect(); mysql_select_db('mailList') or die(mysql_error()); //$file='' $file = $_FILES['tmp_name']; //$presql = CREATE TABLE IF NOT EXISTS (`$_SESSION[SESS_MEMBER_ID]_$file`); $presql = CREATE TABLE IF NOT EXISTS `$_SESSION[SESS_MEMBER_ID]_$file`; $sql = EOF LOAD DATA LOCAL INFILE '{$_FILES['tmp_name']}' INTO TABLE `$_SESSION[SESS_MEMBER_ID]_$file` 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()) { 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(14) emailsTest.txt [type]= string(10) text/plain [tmp_name]= string(14) /tmp/phpq8pi44 [error]= int(0) [size]= int(61) } } Notice: Undefined index: tmp_name in /home/nyctelecomm.com/www/mail/import.php on line 20 Notice: Undefined index: tmp_name in /home/nyctelecomm.com/www/mail/import.php on line 24 $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 ''\' LINES TERMINATED BY \r\n IGNORE 1 LINES' at line 3 From: Roberto Carlos Garcia Luis [mailto:legnakar...@gmail.com javascript:_e(%7b%7d,%20'cvml',%20'legnakar...@gmail.com'); ] Sent: Tuesday, July 24, 2012 5:12 AM To: Brad Cc: php-db@lists.php.net javascript:_e(%7b%7d,%20'cvml',%20'php-db@lists.php.net'); Subject: Re: [PHP-DB] Stuck trying to upload and grab file name In the LOAD DATA LOCAL INFILE '{$_FILES['file']['name']}' You need use The tmp_name to load The file contents. And The SQL var result as a string diferent of The SQL that you insert in console El martes, 24 de julio de 2012, Brad escribió: The tmp_file is just gibberish. I truly do not want that as the table name. From: Roberto Carlos Garcia Luis [mailto:legnakar...@gmail.com] Sent: Tuesday, July 24, 2012 4:26 AM To: Brad Cc: php-db@lists.php.net Subject: Re: [PHP-DB] Stuck trying to upload and grab file name You need to use te tmp_name ... The plain text file is in path indicated by The string... Regards, El martes, 24 de julio de 2012, Brad escribió: I am making a function that uploads a txt file in csv format and the grabs uploaded file name and the memberID from the sessions login and names the new table memberID_filename. The program error on line 24 @ 'name'. I have tried '{$_FILES[file][name]}' '{$_FILES[file]['name']}' '{$_FILES['file']['name']}' {$_FILES[file][name]} {$_FILES['file']['name']} $_FILES[file][name]$_FILES[file]['name'] $_FILES['file']['name'] '$_FILES[file][name]' '$_FILES['file']['name']' and '$_FILES[0]['name']' code* ?php var_dump($_FILES); //db connection require 'dbConnect.php'; //session file require_once('../auth.php'); function uploadList(){ //var_dump($_FILES); if ($_FILES[file][type] == text/plain) { if ($_FILES[file][error] 0) { echo Return Code: . $_FILES['file']['error'] . br /; } else { dbConnect