php-windows Digest 21 May 2007 04:03:03 -0000 Issue 3232

Topics (messages 27911 through 27916):

Re: Textarea and mysql
        27911 by: Dale Attree
        27912 by: Aleksandar Vojnovic
        27913 by: Moore, Joshua
        27914 by: muadib.artrebel9.com
        27915 by: Moore, Joshua

print:bypass the window.
        27916 by: bedul

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
There is only a line break, if the user hits enter, otherwise the textarea
will just wrap the content.

You can use the following:

$textAreaWidth = 60; //Number of cols specified for textarea

$loops = ceil(strlen($_POST['textarea']) / $textAreaWidth);

for($i = 0; $i < $loops; $i++){
        $sp = $i * $textAreaWidth;
        $line = substr($_POST['textarea'],$sp,$textAreaWidth);
        $sql = 'insert into dbTable (fieldname) values ("'.$line.'")';
        Mysql_query($sql) or die(mysql_error());
}

-----Original Message-----
From: Bill Bolte [mailto:[EMAIL PROTECTED] 
Sent: 17 May 2007 11:22 PM
To: [EMAIL PROTECTED]
Subject: RE: [PHP-WIN] Textarea and mysql

Split the data on a line break maybe? First thing that comes into my
head... 

-----Original Message-----
From: Moore, Joshua [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 17, 2007 4:17 PM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] Textarea and mysql

Hello,

 

Im currently having a bit of an issue with putting user info from a
textarea
into mysql db with php. With the textarea I need each new line to be a
separate entry into the db fields. So I guess the end result is making
the
textarea act like a regular text html form. The reason I am using
textarea is
because I want a user to paste in a long string of numbers

Ex:

11111111

22222222

33333333

....and so on

 

And each will end up in the same field just different entries. 

 

Does anyone have any idea how I can accomplish this?

 

Thanks

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






***********************************************************************************************
The information contained in this e-mail is confidential and may be subject to 
legal privilege. 
Access to this e-mail by anyone other than the intended recipient is 
unauthorised.

If you are not the intended recipient you must not use, copy, distribute or 
disclose the e-mail or any part of its contents or take any action in reliance 
on it. If you have received this e-mail in error, please notify us immediately 
by e-mail ([EMAIL PROTECTED]) or telephone (+27 11 265 4200).
This message is free of all known viruses. It has been screened for viruses by 
Blockmail.
***********************************************************************************************

--- End Message ---
--- Begin Message ---

$textareaSubmit = $_POST['textAreaValue'];
//First of all strip all the returns \r
$textareaSubmit = str_replace("\r", "",$textareaSubmit);
//Explode by new line
$inserts = explode("\n", $textareaSubmit);
//check if its array
if(is_array($inserts)){
   //run foreach on array
   foreach($inserts AS $insertSQL){
       $check = false;
$check = mysql_query('INSERT INTO somewhere (`somecolumn`) VALUES (\''.$insertSQL.'\')');
       if($check === true){
           //success
       }else{
           //failure
           //do something?
       }
   }
}

bedul wrote:
$temp = str_replace("\n","[break]",$inpText); //inpText is from textArea

and then u enter your temp to the sql..

when you want to split it up.. just use

$temp=explode("[break]",$inp4Sql); //hope i don't give wrong function

==spam?? sory===
----- Original Message ----- From: "Bill Bolte" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 18, 2007 4:22 AM
Subject: RE: [PHP-WIN] Textarea and mysql


Split the data on a line break maybe? First thing that comes into my
head...
-----Original Message-----
From: Moore, Joshua [mailto:[EMAIL PROTECTED] Sent: Thursday, May 17, 2007 4:17 PM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] Textarea and mysql

Hello,

Im currently having a bit of an issue with putting user info from a
textarea
into mysql db with php. With the textarea I need each new line to be a
separate entry into the db fields. So I guess the end result is making
the
textarea act like a regular text html form. The reason I am using
textarea is
because I want a user to paste in a long string of numbers

Ex:

11111111

22222222

33333333

...and so on

And each will end up in the same field just different entries.
Does anyone have any idea how I can accomplish this?

Thanks


--- End Message ---
--- Begin Message ---
I have two textareas that I need to insert into 2 different fields, so with
the following code im having trouble getting it to work:

Original:
$textareaSubmit = $_POST['textAreaValue'];
//First of all strip all the returns \r
$textareaSubmit = str_replace("\r", "",$textareaSubmit);
//Explode by new line
$inserts = explode("\n", $textareaSubmit);
//check if its array
if(is_array($inserts)){
    //run foreach on array
    foreach($inserts AS $insertSQL){
        $check = false;
        $check = mysql_query('INSERT INTO somewhere (`somecolumn`) 
VALUES (\''.$insertSQL.'\')');
        if($check === true){
            //success
        }else{
            //failure
            //do something?
        }
    }
}

Mine:

$textareaSubmit = $_POST['cpu_asset'];
$textarea2Submit = $_POST['cpu_serial'];
$textareaSubmit = str_replace("\r", "",$textareaSubmit,$textarea2Submit);
//First of all strip all the returns \r
$inserts = explode("\n", $textareaSubmit, $textarea2Submit);  //Explode by
new line
if(is_array($inserts)){ //check if its array
 //run foreach on array
foreach($inserts AS $insertSQL){
        $check = false;
        $check = mysql_query('INSERT INTO labels (`asset, serial`) VALUES
(\''.$insertSQL.'\')');
        if($check === true){
        echo "Done";
        }else{
        echo "An error occured during printing. \n Reason:\n Failed to insert
data into mysql";
                                        }
                                    }
                                }

Mine doesn't work and im not sure why....

Thanks for your help!

-----Original Message-----
From: Aleksandar Vojnovic [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 18, 2007 3:02 AM
To: bedul
Cc: Bill Bolte; [EMAIL PROTECTED]
Subject: Re: [PHP-WIN] Textarea and mysql


$textareaSubmit = $_POST['textAreaValue'];
//First of all strip all the returns \r
$textareaSubmit = str_replace("\r", "",$textareaSubmit);
//Explode by new line
$inserts = explode("\n", $textareaSubmit);
//check if its array
if(is_array($inserts)){
    //run foreach on array
    foreach($inserts AS $insertSQL){
        $check = false;
        $check = mysql_query('INSERT INTO somewhere (`somecolumn`) 
VALUES (\''.$insertSQL.'\')');
        if($check === true){
            //success
        }else{
            //failure
            //do something?
        }
    }
}

bedul wrote:
> $temp = str_replace("\n","[break]",$inpText); //inpText is from textArea
>
> and then u enter your temp to the sql..
>
> when you want to split it up.. just use
>
> $temp=explode("[break]",$inp4Sql); //hope i don't give wrong function
>
> ==spam?? sory===
> ----- Original Message ----- 
> From: "Bill Bolte" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, May 18, 2007 4:22 AM
> Subject: RE: [PHP-WIN] Textarea and mysql
>
>
> Split the data on a line break maybe? First thing that comes into my
> head... 
>
> -----Original Message-----
> From: Moore, Joshua [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, May 17, 2007 4:17 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-WIN] Textarea and mysql
>
> Hello,
>
>  
>
> Im currently having a bit of an issue with putting user info from a
> textarea
> into mysql db with php. With the textarea I need each new line to be a
> separate entry into the db fields. So I guess the end result is making
> the
> textarea act like a regular text html form. The reason I am using
> textarea is
> because I want a user to paste in a long string of numbers
>
> Ex:
>
> 11111111
>
> 22222222
>
> 33333333
>
> ...and so on
>
>  
>
> And each will end up in the same field just different entries. 
>
>  
>
> Does anyone have any idea how I can accomplish this?
>
>  
>
> Thanks
>
>   

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message --- if the $check returns a "false" it would mean that there was an error in your SQL statement. The error might be here:

- > (`asset, serial`)

I doubt you have a column named `asset, serial`

Secondly if you are inserting two values into the SQL then they must be separated with a comma (,).

- > VALUES (\'value1\', \'value2\')

Thirdly :) if you are sure these two texareas are "in sync" you might wanna try to do the following:

for($i = 0; $i < count($inserts); $i++){
...
'INSERT INTO somewhere (`col1`,`col2`) VALUES (\''.$inserts[$i].'\', \''.$otherSyncedArrfay[$i].'\')'
...
}

Hope I was clear enough :)

Aleksander

Quoting "Moore, Joshua" <[EMAIL PROTECTED]>:

I have two textareas that I need to insert into 2 different fields, so with
the following code im having trouble getting it to work:

Original:
$textareaSubmit = $_POST['textAreaValue'];
//First of all strip all the returns \r
$textareaSubmit = str_replace("\r", "",$textareaSubmit);
//Explode by new line
$inserts = explode("\n", $textareaSubmit);
//check if its array
if(is_array($inserts)){
    //run foreach on array
    foreach($inserts AS $insertSQL){
        $check = false;
        $check = mysql_query('INSERT INTO somewhere (`somecolumn`)
VALUES (\''.$insertSQL.'\')');
        if($check === true){
            //success
        }else{
            //failure
            //do something?
        }
    }
}

Mine:

$textareaSubmit = $_POST['cpu_asset'];
$textarea2Submit = $_POST['cpu_serial'];
$textareaSubmit = str_replace("\r", "",$textareaSubmit,$textarea2Submit);
//First of all strip all the returns \r
$inserts = explode("\n", $textareaSubmit, $textarea2Submit);  //Explode by
new line
if(is_array($inserts)){ //check if its array
 //run foreach on array
foreach($inserts AS $insertSQL){
        $check = false;
        $check = mysql_query('INSERT INTO labels (`asset, serial`) VALUES
(\''.$insertSQL.'\')');
        if($check === true){
        echo "Done";
        }else{
        echo "An error occured during printing. \n Reason:\n Failed to insert
data into mysql";
                                        }
                                    }
                                }

Mine doesn't work and im not sure why....

Thanks for your help!

-----Original Message-----
From: Aleksandar Vojnovic [mailto:[EMAIL PROTECTED]
Sent: Friday, May 18, 2007 3:02 AM
To: bedul
Cc: Bill Bolte; [EMAIL PROTECTED]
Subject: Re: [PHP-WIN] Textarea and mysql


$textareaSubmit = $_POST['textAreaValue'];
//First of all strip all the returns \r
$textareaSubmit = str_replace("\r", "",$textareaSubmit);
//Explode by new line
$inserts = explode("\n", $textareaSubmit);
//check if its array
if(is_array($inserts)){
    //run foreach on array
    foreach($inserts AS $insertSQL){
        $check = false;
        $check = mysql_query('INSERT INTO somewhere (`somecolumn`)
VALUES (\''.$insertSQL.'\')');
        if($check === true){
            //success
        }else{
            //failure
            //do something?
        }
    }
}

bedul wrote:
$temp = str_replace("\n","[break]",$inpText); //inpText is from textArea

and then u enter your temp to the sql..

when you want to split it up.. just use

$temp=explode("[break]",$inp4Sql); //hope i don't give wrong function

==spam?? sory===
----- Original Message -----
From: "Bill Bolte" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 18, 2007 4:22 AM
Subject: RE: [PHP-WIN] Textarea and mysql


Split the data on a line break maybe? First thing that comes into my
head...

-----Original Message-----
From: Moore, Joshua [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 17, 2007 4:17 PM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] Textarea and mysql

Hello,



Im currently having a bit of an issue with putting user info from a
textarea
into mysql db with php. With the textarea I need each new line to be a
separate entry into the db fields. So I guess the end result is making
the
textarea act like a regular text html form. The reason I am using
textarea is
because I want a user to paste in a long string of numbers

Ex:

11111111

22222222

33333333

...and so on



And each will end up in the same field just different entries.



Does anyone have any idea how I can accomplish this?



Thanks



--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--- End Message ---
--- Begin Message ---
Please forgive me im still new to programming and php. So this is what I got
from what you said however I guess I managed to screw the whole code up
because it doesn't work at all anymore :(

$textareaSubmit = $_POST['cpu_asset'];
$textarea2Submit = $_POST['cpu_serial'];
$textareaSubmit = str_replace("\r", "",$textareaSubmit); //First of all strip
all the returns \r
$textarea2Submit = str_replace("\r", "",$textarea2Submit); //First of all
strip all the returns \r
$inserts = explode("\n", $textareaSubmit, $textarea2Submit);  //Explode by
new line
                                if(is_array($inserts)){ //check if its array
                                        //run foreach on array
                                        for($i = 0; $i < count($inserts);
$i++){
                                        $check = false;
                                        $check = mysql_query('INSERT INTO
labels (`asset`,`serial`) VALUES (\''.$inserts[$i].'\',
\''.$textarea2Submit[$i].'\')');
        if($check === true){
                echo "Done";
                }else{
                echo "An error occured during printing. \n Reason:\n Failed
to insert data into mysql";
                                                        }
                                                        }
                                                }

Im sure one of the problem area(s) is 

$check = mysql_query('INSERT INTO labels (`asset`,`serial`) VALUES
(\''.$inserts[$i].'\', \''.$textarea2Submit[$i].'\')');

However im not sure what the variable $textarea2Submit[$i] is supposted to
be. Do I need to create a whole other if(is_array($inserts)){ ??

Thanks for your help


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Friday, May 18, 2007 11:11 AM
To: Moore, Joshua
Cc: bedul; Bill Bolte; [EMAIL PROTECTED]
Subject: RE: [PHP-WIN] Textarea and mysql

if the $check returns a "false" it would mean that there was an error  
in your SQL statement. The error might be here:

- > (`asset, serial`)

I doubt you have a column named `asset, serial`

Secondly if you are inserting two values into the SQL then they must  
be separated with a comma (,).

- > VALUES (\'value1\', \'value2\')

Thirdly :) if you are sure these two texareas are "in sync" you might  
wanna try to do the following:

for($i = 0; $i < count($inserts); $i++){
...
'INSERT INTO somewhere (`col1`,`col2`) VALUES (\''.$inserts[$i].'\',  
\''.$otherSyncedArrfay[$i].'\')'
...
}

Hope I was clear enough :)

Aleksander

Quoting "Moore, Joshua" <[EMAIL PROTECTED]>:

> I have two textareas that I need to insert into 2 different fields, so with
> the following code im having trouble getting it to work:
>
> Original:
> $textareaSubmit = $_POST['textAreaValue'];
> //First of all strip all the returns \r
> $textareaSubmit = str_replace("\r", "",$textareaSubmit);
> //Explode by new line
> $inserts = explode("\n", $textareaSubmit);
> //check if its array
> if(is_array($inserts)){
>     //run foreach on array
>     foreach($inserts AS $insertSQL){
>         $check = false;
>         $check = mysql_query('INSERT INTO somewhere (`somecolumn`)
> VALUES (\''.$insertSQL.'\')');
>         if($check === true){
>             //success
>         }else{
>             //failure
>             //do something?
>         }
>     }
> }
>
> Mine:
>
> $textareaSubmit = $_POST['cpu_asset'];
> $textarea2Submit = $_POST['cpu_serial'];
> $textareaSubmit = str_replace("\r", "",$textareaSubmit,$textarea2Submit);
> //First of all strip all the returns \r
> $inserts = explode("\n", $textareaSubmit, $textarea2Submit);  //Explode by
> new line
> if(is_array($inserts)){ //check if its array
>  //run foreach on array
> foreach($inserts AS $insertSQL){
>       $check = false;
>       $check = mysql_query('INSERT INTO labels (`asset, serial`) VALUES
> (\''.$insertSQL.'\')');
>       if($check === true){
>       echo "Done";
>       }else{
>       echo "An error occured during printing. \n Reason:\n Failed to insert
> data into mysql";
>                                       }
>                                   }
>                               }
>
> Mine doesn't work and im not sure why....
>
> Thanks for your help!
>
> -----Original Message-----
> From: Aleksandar Vojnovic [mailto:[EMAIL PROTECTED]
> Sent: Friday, May 18, 2007 3:02 AM
> To: bedul
> Cc: Bill Bolte; [EMAIL PROTECTED]
> Subject: Re: [PHP-WIN] Textarea and mysql
>
>
> $textareaSubmit = $_POST['textAreaValue'];
> //First of all strip all the returns \r
> $textareaSubmit = str_replace("\r", "",$textareaSubmit);
> //Explode by new line
> $inserts = explode("\n", $textareaSubmit);
> //check if its array
> if(is_array($inserts)){
>     //run foreach on array
>     foreach($inserts AS $insertSQL){
>         $check = false;
>         $check = mysql_query('INSERT INTO somewhere (`somecolumn`)
> VALUES (\''.$insertSQL.'\')');
>         if($check === true){
>             //success
>         }else{
>             //failure
>             //do something?
>         }
>     }
> }
>
> bedul wrote:
>> $temp = str_replace("\n","[break]",$inpText); //inpText is from textArea
>>
>> and then u enter your temp to the sql..
>>
>> when you want to split it up.. just use
>>
>> $temp=explode("[break]",$inp4Sql); //hope i don't give wrong function
>>
>> ==spam?? sory===
>> ----- Original Message -----
>> From: "Bill Bolte" <[EMAIL PROTECTED]>
>> To: <[EMAIL PROTECTED]>
>> Sent: Friday, May 18, 2007 4:22 AM
>> Subject: RE: [PHP-WIN] Textarea and mysql
>>
>>
>> Split the data on a line break maybe? First thing that comes into my
>> head...
>>
>> -----Original Message-----
>> From: Moore, Joshua [mailto:[EMAIL PROTECTED]
>> Sent: Thursday, May 17, 2007 4:17 PM
>> To: [EMAIL PROTECTED]
>> Subject: [PHP-WIN] Textarea and mysql
>>
>> Hello,
>>
>>
>>
>> Im currently having a bit of an issue with putting user info from a
>> textarea
>> into mysql db with php. With the textarea I need each new line to be a
>> separate entry into the db fields. So I guess the end result is making
>> the
>> textarea act like a regular text html form. The reason I am using
>> textarea is
>> because I want a user to paste in a long string of numbers
>>
>> Ex:
>>
>> 11111111
>>
>> 22222222
>>
>> 33333333
>>
>> ...and so on
>>
>>
>>
>> And each will end up in the same field just different entries.
>>
>>
>>
>> Does anyone have any idea how I can accomplish this?
>>
>>
>>
>> Thanks
>>
>>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
to execute print.. i always use
<script>
 window.print();
 
 </script>

that's script above will execute print when i enter my page (which is will 
print)


but the problem i have was.. 
how to make user don't see print window but he/she will print and by pass the 
print window?
if that a matter of security, i will agree with you.

is there a way to by pass the print window.
thx in advance


--- End Message ---

Reply via email to