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

2012-07-24 Thread Brad
I wanted to start off by saying thank you to the list for your warm support.

I was working with jonez from irc.oftc.net #php and we were able to far
enough into the issue for me to realize I'm an idiot.

I am creating a new table like I wanted but should be creating new field due
to a little paradox I create myself with the need for at least one field in
the creation process.

I should be creating a new field anyways.

 

Here is the updated code but it will be changing a lot in a few moments.

 

 

 0)

{

echo "Return Code: " . $file['error'] . "";

}

else

{

dbConnect();

mysql_select_db('mailList') or die(mysql_error());

$tmp_name =  $file["tmp_name"];

//$presql = "CREATE TABLE IF NOT EXISTS
{$memberID}_{$file}";

$presql = "CREATE TABLE IF NOT EXISTS dumb_table";

$sql = <<



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

2012-07-24 Thread Pavan puligandla
Wtf, whts happening here??? Getting freakin hundreds of emails, if you got 
stuckup, you need to resolve it by urself, dont email for silly doubts..

Sent from my smart phone

-Original message-
From: Graham H.
Sent:  24/07/2012, 10:16  pm
To: jim.gi...@albanyhandball.com
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Re: Stuck trying to upload and grab file name



Okay.

That line is also in the Pastie code :) Though it isn't in the OP. Hence my
(and your) confusion now. Line 20 from here: http://pastie.org/4317155 also
line 24.

On Tue, Jul 24, 2012 at 10:44 AM, Jim Giner wrote:

> On 7/24/2012 12:40 PM, Graham H. wrote:
>
>> If by "the line" you mean:   ["tmp_name"]=> string(14) "/tmp/phpcLtE6W"
>>
>> That is from the bottom of this Pastie link: http://pastie.org/4317155
>>
>>
>>> $file = $_FILES["file"]["tmp_name"];
>>>
>>>
>>>  I meant the above line.
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Graham Holtslander
Computer Systems Technologist
www.graham.holtslander.com
mene...@gmail.com


--
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-24 Thread Graham H.
Okay.

That line is also in the Pastie code :) Though it isn't in the OP. Hence my
(and your) confusion now. Line 20 from here: http://pastie.org/4317155 also
line 24.

On Tue, Jul 24, 2012 at 10:44 AM, Jim Giner wrote:

> On 7/24/2012 12:40 PM, Graham H. wrote:
>
>> If by "the line" you mean:   ["tmp_name"]=> string(14) "/tmp/phpcLtE6W"
>>
>> That is from the bottom of this Pastie link: http://pastie.org/4317155
>>
>>
>>> $file = $_FILES["file"]["tmp_name"];
>>>
>>>
>>>  I meant the above line.
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Graham Holtslander
Computer Systems Technologist
www.graham.holtslander.com
mene...@gmail.com


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

2012-07-24 Thread Jim Giner

On 7/24/2012 12:40 PM, Graham H. wrote:

If by "the line" you mean:   ["tmp_name"]=> string(14) "/tmp/phpcLtE6W"

That is from the bottom of this Pastie link: http://pastie.org/4317155



$file = $_FILES["file"]["tmp_name"];



I meant the above line.

--
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-24 Thread Jim Giner

On 7/24/2012 4:16 AM, Brad wrote:

 $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 = <<
Brad,
Since you have defined a var $file containing what you need, why don't 
you use that var in your LOAD DATA line, instead of the convoluted 
$_FILES reference?


If I may ask, what does the reference to $_SESSION[SESS_MEMBER_ID] 
accomplish?  Haven' had an occasion to do this.


I'm also wondering if the error you are receiving has anything to do 
with the name.  It may be the syntax using those slashes as delimiter chars.


--
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-24 Thread Graham H.
If by "the line" you mean:   ["tmp_name"]=> string(14) "/tmp/phpcLtE6W"

That is from the bottom of this Pastie link: http://pastie.org/4317155

On Tue, Jul 24, 2012 at 10:29 AM, Jim Giner wrote:

>
> On 7/24/2012 12:05 PM, Graham H. wrote:
>
>> Does the problem have anything to do with this:
>>
>>
>>   ["tmp_name"]=> string(14) "/tmp/phpcLtE6W"
>>
>> So this:
>>
>> $file = $_FILES["file"]["tmp_name"];
>>
>> Would make $file == "/tmp/phpcLtE6W"
>>
>> I'm not sure if that's what you want. Seems more likely that you'd want it
>> to be:
>>
>> $file = $_FILES["file"]["name"];
>>
>> Useful?
>>
>>
>>  Graham,
> The line you reference - I don't see that in my code (which is production
> code) nor in the OP's code.
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Graham Holtslander
Computer Systems Technologist
www.graham.holtslander.com
mene...@gmail.com


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

2012-07-24 Thread Jim Giner


On 7/24/2012 12:05 PM, Graham H. wrote:

Does the problem have anything to do with this:


  ["tmp_name"]=> string(14) "/tmp/phpcLtE6W"

So this:

$file = $_FILES["file"]["tmp_name"];

Would make $file == "/tmp/phpcLtE6W"

I'm not sure if that's what you want. Seems more likely that you'd want it
to be:

$file = $_FILES["file"]["name"];

Useful?



Graham,
The line you reference - I don't see that in my code (which is 
production code) nor in the OP's code.


--
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-24 Thread Graham H.
Does the problem have anything to do with this:


 ["tmp_name"]=> string(14) "/tmp/phpcLtE6W"

So this:

$file = $_FILES["file"]["tmp_name"];

Would make $file == "/tmp/phpcLtE6W"

I'm not sure if that's what you want. Seems more likely that you'd want it
to be:

$file = $_FILES["file"]["name"];

Useful?

On Tue, Jul 24, 2012 at 9:18 AM, Brad  wrote:

> Thank you very much my friend.
> The significant difference between your code and mine is that my file
> contents are going into a MySQL database and it is this db function that is
> crapping out. The SQL (with variables replaced with static values) runs
> clean ->  http://pastie.org/4302489
> But as soon as you throw in a variable/dynamic value, it just becomes a
> mess.
>
> Brad
>
>
> -Original Message-
> From: Jim Giner [mailto:jim.gi...@albanyhandball.com]
> Sent: Tuesday, July 24, 2012 8:45 AM
> To: php-db@lists.php.net
> Subject: [PHP-DB] Re: Stuck trying to upload and grab file name
>
> At the risk of being unable to understand all the posts that are here
> already,  here is some std. code that I use when I'm uploading a file.
>
> First - i capture the input field in a local var and all of its components
> in other local vars to make my coding easier later on.
>
> $inputfield = $_POST['infile'];// infile is the html name of the
> type='file' field
> $destfolder = (where I want the end result stored) $outfile = (the filename
> of the end result) $result =
> HandleUploadedFile($inputfield,$destfolder,$outfile);
> (handle $result after return)
> ***
>
> The function I use:
>
> function HandleUploadedFile($inputfield,$destfolder,$outfile)
> {// parm 1 is the name of the type=file field in the html; 2 & 3 are
> path and output filename you want to store it in
>  global $msg,$ftype,$ferror,$fname,$fsize,$ftmpname;
>  $ftype = $_FILES[$inputfield]["type"];
>  $ferror = $_FILES[$inputfield]["error"];
>  $fname = $_FILES[$inputfield]["name"];
>  $fsize = $_FILES[$inputfield]["size"];
>  $ftmpname = $_FILES[$inputfield]["tmp_name"];
>  // code up acceptabe filetypes here
>  if ( $ftype == "text/plain")
>  {
>  if ($ferror > 0)
>  {
>  $msg .= ' Upload error - return code was '.$ferror;
>  return False;
>  }
>  else
>  {
>  if (file_exists($destfolder . $fname))
>  {
>  $msg .= " Duplicate filename - upload not done,
> continuing.";
>  return True;
>  }
>  else
>  {
>  $msg .= " File has been uploaded to: " . $destfolder
> .$outfile;
>  move_uploaded_file($ftmpname,$destfolder . $outfile);
>  return True;
>  }
>  }
>  }
>  else
>  {
>  $msg .= " Invalid file type for menu input upload";
>  $msg .= " Type is ".$ftype;
>  return False;
>  }
> }
>
>
> You of course want to name your end result like the original filename, so
> you will have to make a change to that parameter, but this will work for
> you.
>
> --
> 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
>
>


-- 
Graham Holtslander
Computer Systems Technologist
www.graham.holtslander.com
mene...@gmail.com


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

2012-07-24 Thread Brad
Thank you very much my friend.
The significant difference between your code and mine is that my file
contents are going into a MySQL database and it is this db function that is
crapping out. The SQL (with variables replaced with static values) runs
clean ->  http://pastie.org/4302489 
But as soon as you throw in a variable/dynamic value, it just becomes a
mess.

Brad


-Original Message-
From: Jim Giner [mailto:jim.gi...@albanyhandball.com] 
Sent: Tuesday, July 24, 2012 8:45 AM
To: php-db@lists.php.net
Subject: [PHP-DB] Re: Stuck trying to upload and grab file name

At the risk of being unable to understand all the posts that are here
already,  here is some std. code that I use when I'm uploading a file.

First - i capture the input field in a local var and all of its components
in other local vars to make my coding easier later on.

$inputfield = $_POST['infile'];// infile is the html name of the 
type='file' field
$destfolder = (where I want the end result stored) $outfile = (the filename
of the end result) $result =
HandleUploadedFile($inputfield,$destfolder,$outfile);
(handle $result after return)
***

The function I use:

function HandleUploadedFile($inputfield,$destfolder,$outfile)
{// parm 1 is the name of the type=file field in the html; 2 & 3 are 
path and output filename you want to store it in
 global $msg,$ftype,$ferror,$fname,$fsize,$ftmpname;
 $ftype = $_FILES[$inputfield]["type"];
 $ferror = $_FILES[$inputfield]["error"];
 $fname = $_FILES[$inputfield]["name"];
 $fsize = $_FILES[$inputfield]["size"];
 $ftmpname = $_FILES[$inputfield]["tmp_name"];
 // code up acceptabe filetypes here
 if ( $ftype == "text/plain")
 {
 if ($ferror > 0)
 {
 $msg .= ' Upload error - return code was '.$ferror;
 return False;
 }
 else
 {
 if (file_exists($destfolder . $fname))
 {
 $msg .= " Duplicate filename - upload not done,
continuing.";
 return True;
 }
 else
 {
 $msg .= " File has been uploaded to: " . $destfolder
.$outfile;
 move_uploaded_file($ftmpname,$destfolder . $outfile);
 return True;
 }
 }
 }
 else
 {
 $msg .= " Invalid file type for menu input upload";
 $msg .= " Type is ".$ftype;
 return False;
 }
}


You of course want to name your end result like the original filename, so
you will have to make a change to that parameter, but this will work for
you.

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

2012-07-24 Thread Brad
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ó:

 0)

{

echo "Return Code: " . $_FILES['file']['error'] .
"";

}

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

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



 0)

{

echo "Return Code: " . $_FILES['file']['error'] .
"";

}

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

IGNORE 1 LINES

EOF;

mysql_query($presql);

mysql_query($sql);

var_dump($sql);

echo '$sql';

if(mysql_error())

{

echo(mysql_error());

   



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

2012-07-24 Thread Jim Giner
At the risk of being unable to understand all the posts that are here 
already,  here is some std. code that I use when I'm uploading a file.


First - i capture the input field in a local var and all of its 
components in other local vars to make my coding easier later on.


$inputfield = $_POST['infile'];// infile is the html name of the 
type='file' field

$destfolder = (where I want the end result stored)
$outfile = (the filename of the end result)
$result = HandleUploadedFile($inputfield,$destfolder,$outfile);
(handle $result after return)
***

The function I use:

function HandleUploadedFile($inputfield,$destfolder,$outfile)
{// parm 1 is the name of the type=file field in the html; 2 & 3 are 
path and output filename you want to store it in

global $msg,$ftype,$ferror,$fname,$fsize,$ftmpname;
$ftype = $_FILES[$inputfield]["type"];
$ferror = $_FILES[$inputfield]["error"];
$fname = $_FILES[$inputfield]["name"];
$fsize = $_FILES[$inputfield]["size"];
$ftmpname = $_FILES[$inputfield]["tmp_name"];
// code up acceptabe filetypes here
if ( $ftype == "text/plain")
{
if ($ferror > 0)
{
$msg .= ' Upload error - return code was '.$ferror;
return False;
}
else
{
if (file_exists($destfolder . $fname))
{
$msg .= " Duplicate filename - upload not done, 
continuing.";

return True;
}
else
{
$msg .= " File has been uploaded to: " . $destfolder 
.$outfile;

move_uploaded_file($ftmpname,$destfolder . $outfile);
return True;
}
}
}
else
{
$msg .= " Invalid file type for menu input upload";
$msg .= " Type is ".$ftype;
return False;
}
}


You of course want to name your end result like the original filename, 
so you will have to make a change to that parameter, but this will work 
for you.


--
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-24 Thread Brad
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ó:

 0)

{

echo "Return Code: " . $_FILES['file']['error'] .
"";

}

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

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



 0)

{

echo "Return Code: " . $_FILES['file']['error'] .
"";

}

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

IGNORE 1 LINES

EOF;

mysql_query($presql);

mysql_query($sql);

var_dump($sql);

echo '$sql';

 

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

2012-07-24 Thread Roberto Carlos Garcia Luis
Use

$_FILES["file"]["tmp_name"]

El martes, 24 de julio de 2012, Brad escribió:

> 
> 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'] .
> "";
>
> }
>
> 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 = <<
> 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 'legnakar...@gmail.com');>]
>
> *Sent:* Tuesday, July 24, 2012 5:12 AM
> *To:* Brad
> *Cc:* php-db@lists.php.net  '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*
>
>
>
> 
> var_dump($_FILES);
>
> //db connection
>
> require 'dbConnect.php';
>
> //session file
>
> require_once('../auth.php');
>
> function uploadList(){
>
> //var_dump($_FILES);
>
> if ($_FILES["file"][

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

2012-07-24 Thread Brad
 0)

{

echo "Return Code: " . $_FILES['file']['error'] .
"";

}

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

 

 

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



 0)

{

echo "Return Code: " . $_FILES['file']['error'] .
"";

}

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

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

2012-07-24 Thread Roberto Carlos Garcia Luis
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 'legnakar...@gmail.com');>]
>
> *Sent:* Tuesday, July 24, 2012 4:26 AM
> *To:* Brad
> *Cc:* php-db@lists.php.net  '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*
>
>
>
> 
> 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'] .
> "";
>
> }
>
> 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 = <<
> 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

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



 0)

{

echo "Return Code: " . $_FILES['file']['error'] .
"";

}

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

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

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



 0)

{

echo "Return Code: " . $_FILES['file']['error'] .
"";

}

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

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

2012-07-24 Thread Roberto Carlos Garcia Luis
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*
>
>
>
> 
> 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'] .
> "";
>
> }
>
> 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 = <<
> 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

2012-07-24 Thread Roberto Carlos Garcia Luis
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*
>
>
>
> 
> 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'] .
> "";
>
> }
>
> 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 = <<
> 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) }
>
>
>
>
>
>


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

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

 

 0)

{

echo "Return Code: " . $_FILES['file']['error'] .
"";

}

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

 

 

 

 

**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) }