Re: [PHP-DB] Stuck trying to upload and grab file name

2012-07-25 Thread Tamara Temple
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

2012-07-25 Thread Matijn Woudt
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

2012-07-25 Thread Karl DeSaulniers

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



[PHP-DB] Re: Stuck trying to upload and grab file name

2012-07-25 Thread Brad
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

 



Re: [PHP-DB] Re: Stuck trying to upload and grab file name

2012-07-25 Thread Karl DeSaulniers

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-DB] Re: Stuck trying to upload and grab file name

2012-07-25 Thread Brad
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())

{

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



RE: [PHP-DB] Re: Stuck trying to upload and grab file name

2012-07-25 Thread Brad
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] 
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())

   {

   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



RE: [PHP-DB] Re: Stuck trying to upload and grab file name

2012-07-25 Thread Brad
Unfortunately that has already been done and that exact method is what got
me this far. I can visually confirm that I am calling on the correct
names/variables.

array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt
[type]= string(10) text/plain [tmp_name]= string(14)
/tmp/phpec4hX9 [error]= int(0) [size]= int(61) } } array(5) {
[name]= string(14) emailsTest.txt [type]= string(10) text/plain
[tmp_name]= string(14) /tmp/phpec4hX9 [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

Brad


-Original Message-
From: lists-php [mailto:replies-lists-d5y3-...@listmail.innovate.net] 
Sent: Wednesday, July 25, 2012 7:55 PM
To: Brad
Subject: RE: [PHP-DB] Re: Stuck trying to upload and grab file name



 Original Message 
 Date: Wednesday, July 25, 2012 07:33:09 PM -0400
 From: Brad nyctelec...@gmail.com
 To: 'Karl DeSaulniers' k...@designdrumm.com
 Cc: php-db@lists.php.net
 Subject: RE: [PHP-DB] Re: Stuck trying to upload and grab file name

 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
 

Echo the statement out (after the variable substitutions have taken place),
and then work with that at the mysql command line. You'll likely figure out
the issue much faster (it might even be obvious from what gets displayed).

   - Richard

 


-- 
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

2012-07-25 Thread Roberto Carlos Garcia Luis
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] Re: Stuck trying to upload and grab file name

2012-07-25 Thread Brad
Updated code with var_dump;
https://gist.github.com/3179506

Brad


-Original Message-
From: lists-php [mailto:replies-lists-d5y3-...@listmail.innovate.net] 
Sent: Wednesday, July 25, 2012 7:55 PM
To: Brad
Subject: RE: [PHP-DB] Re: Stuck trying to upload and grab file name



 Original Message 
 Date: Wednesday, July 25, 2012 07:33:09 PM -0400
 From: Brad nyctelec...@gmail.com
 To: 'Karl DeSaulniers' k...@designdrumm.com
 Cc: php-db@lists.php.net
 Subject: RE: [PHP-DB] Re: Stuck trying to upload and grab file name

 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
 

Echo the statement out (after the variable substitutions have taken place),
and then work with that at the mysql command line. You'll likely figure out
the issue much faster (it might even be obvious from what gets displayed).

   - Richard

 


-- 
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

2012-07-25 Thread Brad
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())

   {

 



RE: [PHP-DB] Re: Stuck trying to upload and grab file name

2012-07-25 Thread Brad
That's a little presumptuous don't you think?
I runs without error now but my test data is not in the database?

array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt
[type]= string(10) text/plain [tmp_name]= string(14)
/tmp/phpkVycB6 [error]= int(0) [size]= int(61) } } Import of
campaign emails sucessfull into mysql table.

?php
var_dump($_FILES);
//db connection
require 'dbConnect.php';
//session file
require_once('../auth.php');
function uploadList(){
$file = $_FILES[file];
//var_dump($_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);
$midsql = ALTER TABLE `{$memberID}` ADD {$file}
VARCHAR(60);
$sql = EOF
LOAD DATA LOCAL INFILE '{$tmp_name}'
INTO TABLE `{$memberID}`
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY
'\\''
LINES TERMINATED BY \\r\\n
IGNORE 1 LINES
EOF;
//var_dump($sql);
//echo '$sql';
mysql_query($presql);
mysql_query($midsql);
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();
?




Brad Sumrall
NYCTelecomm.com
212 444-2996


-Original Message-
From: lists-php [mailto:replies-lists-d5y3-...@listmail.innovate.net] 
Sent: Wednesday, July 25, 2012 9:35 PM
To: Brad
Subject: RE: [PHP-DB] Re: Stuck trying to upload and grab file name

Is this supposed to be what you submitted to mysql? I suspect not, as among
things, it includes the returned mysql error.

Sorry, but I don't think you get the basics of debugging code.

I would suggest that you find someone who is willing to give you sample code
and help you **off list** (this level of tutorial really doesn't belong on a
mailing list).

Good luck.



 Original Message 
 Date: Wednesday, July 25, 2012 09:24:53 PM -0400
 From: Brad nyctelec...@gmail.com
 To: 'lists-php' replies-lists-d5y3-...@listmail.innovate.net
 Subject: RE: [PHP-DB] Re: Stuck trying to upload and grab file name

 https://gist.github.com/3179723
 
 array(1) { [file]= array(5) { [name]= string(14) 
 emailsTest.txt [type]= string(10) text/plain [tmp_name]=
 string(14) /tmp/phpepEKoj [error]= int(0) [size]= int(61) } } 
 string(188)  LOAD DATA LOCAL INFILE '/tmp/phpepEKoj' ALTER TABLE `3` 
 ADD Array VARCHAR(60); FIELDS TERMINATED BY ','
 OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY \r\n IGNORE 1 LINES 
 $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
 
 -Original Message-
 From: lists-php
 [mailto:replies-lists-d5y3-...@listmail.innovate.net]  Sent:
 Wednesday, July 25, 2012 8:57 PM
 To: Brad
 Subject: RE: [PHP-DB] Re: Stuck trying to upload and grab file name
 
 No. What you have there is the dump *after* you've passed things to 
 mysql -- including the mysql error. Look at what you are passing to 
 mysql *before* you actually feed it to mysql.
 
 I suspect you are missing a mysql command terminator (semicolon) or 
 two so you are running commands together. E.g., after the load data 
 command -- but it's mostly impossible to tell without cleaner detail.
 
 Just as a general coding practice issue -- why are you trying to 
 string that group of commands into one set that you dump to mysql in a 
 single set. It would be much cleaner, and more controllable, to do the 
 different mysql commands as separate statements.
 
 
  Original Message 
 Date: Wednesday, July 25, 2012 08:43:51 PM -0400
 From: Brad nyctelec...@gmail.com
 To: 'lists-php'  
 Subject: RE: [PHP-DB] Re: Stuck trying to upload and grab file name
 
 I 

[PHP-DB] No data?

2012-07-25 Thread Brad
My code runs error free but no data actually makes it into the database?  -
http://pastie.org/4333923  and it creates a second column called Array
(which isn't correct).  :(

I can see the temporary file being created but I can't see what I am doing
wrong. The second column is a red flag but I can't see what?



Re: [PHP-DB] Re: Stuck trying to upload and grab file name

2012-07-25 Thread Karl DeSaulniers

Brad,
Try this and let me know if it worked. I'm curious.

$fileData = $_FILES['file'];

...

dbConnect();
mysql_select_db('mailList') or die(mysql_error());
$presql = CREATE TABLE IF NOT EXISTS  
`.mysql_real_escape_string($memberID).` (id MEDIUMINT AUTO_INCREMENT  
PRIMARY KEY UNIQUE);
$midsql = ALTER TABLE `.mysql_real_escape_string($memberID).` ADD  
'.mysql_real_escape_string($fileData).' VARCHAR(60);
$sql = LOAD DATA LOCAL INFILE  
'.mysql_real_escape_string($_FILES['tmp_name']).' INTO TABLE  
`.mysql_real_escape_string($memberID).` FIELDS TERMINATED BY '\,'  
OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY \r\n IGNORE 1 LINES;


...

Best,
Karl


$file

On Jul 25, 2012, at 8:57 PM, Brad wrote:


That's a little presumptuous don't you think?
I runs without error now but my test data is not in the database?

array(1) { [file]= array(5) { [name]= string(14)  
emailsTest.txt

[type]= string(10) text/plain [tmp_name]= string(14)
/tmp/phpkVycB6 [error]= int(0) [size]= int(61) } } Import of
campaign emails sucessfull into mysql table.

?php
var_dump($_FILES);
//db connection
require 'dbConnect.php';
//session file
require_once('../auth.php');
function uploadList(){
   $file = $_FILES[file];
   //var_dump($_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);
   $midsql = ALTER TABLE `{$memberID}` ADD  
{$file}

VARCHAR(60);
   $sql = EOF
   LOAD DATA LOCAL INFILE '{$tmp_name}'
   INTO TABLE `{$memberID}`
   FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY
'\\''
   LINES TERMINATED BY \\r\\n
   IGNORE 1 LINES
EOF;
   //var_dump($sql);
   //echo '$sql';
   mysql_query($presql);
   mysql_query($midsql);
   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();
?




Brad Sumrall
NYCTelecomm.com
212 444-2996


-Original Message-
From: lists-php [mailto:replies-lists-d5y3-...@listmail.innovate.net]
Sent: Wednesday, July 25, 2012 9:35 PM
To: Brad
Subject: RE: [PHP-DB] Re: Stuck trying to upload and grab file name

Is this supposed to be what you submitted to mysql? I suspect not,  
as among

things, it includes the returned mysql error.

Sorry, but I don't think you get the basics of debugging code.

I would suggest that you find someone who is willing to give you  
sample code
and help you **off list** (this level of tutorial really doesn't  
belong on a

mailing list).

Good luck.



 Original Message 

Date: Wednesday, July 25, 2012 09:24:53 PM -0400
From: Brad nyctelec...@gmail.com
To: 'lists-php' replies-lists-d5y3-...@listmail.innovate.net
Subject: RE: [PHP-DB] Re: Stuck trying to upload and grab file name

https://gist.github.com/3179723

array(1) { [file]= array(5) { [name]= string(14)
emailsTest.txt [type]= string(10) text/plain [tmp_name]=
string(14) /tmp/phpepEKoj [error]= int(0) [size]= int(61) } }
string(188)  LOAD DATA LOCAL INFILE '/tmp/phpepEKoj' ALTER TABLE `3`
ADD Array VARCHAR(60); FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY \r\n IGNORE 1  
LINES

$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

-Original Message-
From: lists-php
[mailto:replies-lists-d5y3-...@listmail.innovate.net]  Sent:
Wednesday, July 25, 2012 8:57 PM
To: Brad
Subject: RE: [PHP-DB] Re: Stuck trying to upload and grab file name

No. What you have there is the dump *after* you've passed things to
mysql -- including the mysql error. Look at what you are passing to
mysql *before* you actually feed it to mysql.

I suspect you are missing a mysql 

RE: [PHP-DB] Re: Stuck trying to upload and grab file name

2012-07-25 Thread Brad
Same thing

?php
var_dump($_FILES);
//db connection
require 'dbConnect.php';
//session file
require_once('../auth.php');
function uploadList(){
$fileData = $_FILES[file];
var_dump($_FILES[file]);
var_dump($_FILES);
$memberID = $_SESSION[SESS_MEMBER_ID];
if ($fileData[type] == text/plain)
{
if ($fileData[error]  0)
{
echo Return Code:  . $fileData['error'] . br
/;
}
else
{
dbConnect();
mysql_select_db('mailList') or die(mysql_error());
$tmp_name =  $fileData[tmp_name];
$presql = CREATE TABLE IF NOT EXISTS `{$memberID}`
(id MEDIUMINT AUTO_INCREMENT PRIMARY KEY UNIQUE);
$midsql = ALTER TABLE `{$memberID}` ADD {$fileData}
VARCHAR(60);
$sql = EOF
LOAD DATA LOCAL INFILE '{$tmp_name}'
INTO TABLE `{$memberID}`
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY
'\\''
LINES TERMINATED BY \\r\\n
IGNORE 1 LINES
EOF;
var_dump($sql);
echo '$sql';
mysql_query($presql);
mysql_query($midsql);
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();
?

***

SHOW CREATE TABLE `3`;
+---+---

+
| Table | Create Table
|
+---+---

+
| 3 | CREATE TABLE `3` (
  `id` mediumint(9) NOT NULL AUTO_INCREMENT,
  `Array` varchar(60) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 |
+---+---

+
1 row in set (0.00 sec)

mysql SELECT * FROM `3`;
++---+
| id | Array |
++---+
|  1 | NULL  |
|  2 | NULL  |
|  3 | NULL  |
|  4 | NULL  |
|  5 | NULL  |
|  6 | NULL  |
|  7 | NULL  |
|  8 | NULL  |
|  9 | NULL  |
| 10 | NULL  |
| 11 | NULL  |
| 12 | NULL  |
++---+
12 rows in set (0.00 sec)


*









array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt
[type]= string(10) text/plain [tmp_name]= string(14)
/tmp/phpKeJFI0 [error]= int(0) [size]= int(61) } } array(5) {
[name]= string(14) emailsTest.txt [type]= string(10) text/plain
[tmp_name]= string(14) /tmp/phpKeJFI0 [error]= int(0) [size]=
int(61) } array(1) { [file]= array(5) { [name]= string(14)
emailsTest.txt [type]= string(10) text/plain [tmp_name]=
string(14) /tmp/phpKeJFI0 [error]= int(0) [size]= int(61) } }
string(165) LOAD DATA LOCAL INFILE '/tmp/phpKeJFI0' INTO TABLE `3`
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY
\r\n IGNORE 1 LINES $sqlstring(165)  LOAD DATA LOCAL INFILE
'/tmp/phpKeJFI0' INTO TABLE `3` FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED
BY '\'' LINES TERMINATED BY \r\n IGNORE 1 LINES $sqlImport of campaign
emails sucessfull into mysql table.



-Original Message-
From: Karl DeSaulniers [mailto:k...@designdrumm.com] 
Sent: Wednesday, July 25, 2012 10:46 PM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Re: Stuck trying to upload and grab file name

Brad,
Try this and let me know if it worked. I'm curious.

$fileData = $_FILES['file'];

...

dbConnect();
mysql_select_db('mailList') or die(mysql_error()); $presql = CREATE TABLE
IF NOT EXISTS `.mysql_real_escape_string($memberID).` (id MEDIUMINT
AUTO_INCREMENT PRIMARY KEY UNIQUE); $midsql = ALTER TABLE
`.mysql_real_escape_string($memberID).` ADD
'.mysql_real_escape_string($fileData).' VARCHAR(60); $sql = LOAD DATA
LOCAL INFILE 

[PHP-DB] No data?

2012-07-25 Thread Brad
Note this var_dump

array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt
[type]= string(10) text/plain [tmp_name]= string(14)
/tmp/phpOxqCnD [error]= int(0) [size]= int(61) } } array(1) {
[file]= array(5) { [name]= string(14) emailsTest.txt [type]=
string(10) text/plain [tmp_name]= string(14) /tmp/phpOxqCnD
[error]= int(0) [size]= int(61) } } string(165)  LOAD DATA LOCAL
INFILE '/tmp/phpOxqCnD' INTO TABLE `3` FIELDS TERMINATED BY ',' OPTIONALLY
ENCLOSED BY '\'' LINES TERMINATED BY \r\n IGNORE 1 LINES $sqlDuplicate
column name 'Array'


array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt
is where my problem is.
On my line 8   -  $fileData = $_FILES[file]; if I switch it to 'name'
(like I am thinking it should be) I get an undefined variable error. With it
as 'file', I get no error but no data either.


Code:
*
?php
var_dump($_FILES);
//db connection
require 'dbConnect.php';
//session file
require_once('../auth.php');
function uploadList(){
$fileData = $_FILES[file];
//$fileData = [name];
//var_dump($_FILES[name]);
var_dump($_FILES);
$memberID = $_SESSION[SESS_MEMBER_ID];
if ($fileData[type] == text/plain)
{
if ($fileData[error]  0)
{
echo Return Code:  . $fileData['error'] . br /;
}
else
{
dbConnect();
mysql_select_db('mailList') or die(mysql_error());
$tmp_name = $fileData[tmp_name];
$presql = CREATE TABLE IF NOT EXISTS `{$memberID}` (id MEDIUMINT
AUTO_INCREMENT PRIMARY KEY UNIQUE);
$midsql = ALTER TABLE `{$memberID}` ADD {$fileData} VARCHAR(60);
$sql = EOF
LOAD DATA LOCAL INFILE '{$tmp_name}'
INTO TABLE `{$memberID}`
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\\''
LINES TERMINATED BY \\r\\n
IGNORE 1 LINES
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();
?

***

mysql SHOW CREATE TABLE `3`;
+---+---

+
| Table | Create Table |
+---+---

+
| 3 | CREATE TABLE `3` (
`id` mediumint(9) NOT NULL AUTO_INCREMENT,
`Array` varchar(60) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 |
+---+---

+
1 row in set (0.00 sec)

mysql SELECT * FROM `3`;
++---+
| id | Array |
++---+
| 1 | NULL |
| 2 | NULL |
| 3 | NULL |
| 4 | NULL |
| 5 | NULL |
| 6 | NULL |
| 7 | NULL |
| 8 | NULL |
| 9 | NULL |
| 10 | NULL |
| 11 | NULL |
| 12 | NULL |
++---+
12 rows in set (0.00 sec)

**

 

Brad