php-general Digest 5 Jan 2009 14:29:45 -0000 Issue 5884
Topics (messages 285442 through 285452):
A beginner´s question
285442 by: Eduardo
285443 by: Nathan Rixham
285444 by: Micah Gersten
285446 by: TG
285448 by: Micah Gersten
285449 by: Micah Gersten
285450 by: Vicente
Re: A beginner´s question
285445 by: Vicente
285447 by: Vicente
Re: How to count transfered kBytes in File-Download
285451 by: Jim Lucas
setting up FTP account names via PHP
285452 by: Merlin Morgenstern
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 ---
Hi, I am Eduardo, a new PHP programmer and an old Cobol veteran.
I know that
$tastes=$_POST["tastes"];
moves the content of "tastes" from
<p><textarea rows="5" name="tastes" cols="28"></textarea></p>
to
$tastes
How do I move the content of $tastes to X of
echo "<textarea rows="5" cols="28" readonly name=X>\n";
?
Thanks,
Eduardo
--- End Message ---
--- Begin Message ---
Eduardo wrote:
Hi, I am Eduardo, a new PHP programmer and an old Cobol veteran.
I know that
$tastes=$_POST["tastes"];
moves the content of "tastes" from
<p><textarea rows="5" name="tastes" cols="28"></textarea></p>
to
$tastes
How do I move the content of $tastes to X of
echo "<textarea rows="5" cols="28" readonly name=X>\n";
?
Thanks,
Eduardo
echo "<textarea rows="5" cols="28" readonly name=" . $tastes . ">\n";
echo "this is how you echo a " . $variable . " in a string";
--- End Message ---
--- Begin Message ---
Nathan Rixham wrote:
> Eduardo wrote:
>> Hi, I am Eduardo, a new PHP programmer and an old Cobol veteran.
>> I know that
>> $tastes=$_POST["tastes"]; moves the content of "tastes" from
>> <p><textarea rows="5" name="tastes" cols="28"></textarea></p>
>> to
>> $tastes
>>
>>
>> How do I move the content of $tastes to X of
>> echo "<textarea rows="5" cols="28" readonly name=X>\n";
>> ?
>>
>> Thanks, Eduardo
>>
>
> echo "<textarea rows="5" cols="28" readonly name=" . $tastes . ">\n";
>
> echo "this is how you echo a " . $variable . " in a string";
>
While that is true, that's probably not what the OP wants.
He's probably looking for:
echo "<textarea rows="5" cols="28" readonly
name="tastes">$tastes</textarea>\n";
Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com
--- End Message ---
--- Begin Message ---
----- Original Message -----
From: Nathan Rixham <[email protected]>
To: Eduardo <[email protected]>
Cc: [email protected]
Date: Mon, 05 Jan 2009 03:00:19 +0000
Subject: [PHP] Re: A beginner´s question
> Eduardo wrote:
> > Hi, I am Eduardo, a new PHP programmer and an old Cobol veteran.
> > I know that
> > $tastes=$_POST["tastes"];
> > moves the content of "tastes" from
> > <p><textarea rows="5" name="tastes" cols="28"></textarea></p>
> > to
> > $tastes
> >
> >
> > How do I move the content of $tastes to X of
> > echo "<textarea rows="5" cols="28" readonly name=X>\n";
> > ?
> >
> > Thanks,
> > Eduardo
> >
>
> echo "<textarea rows="5" cols="28" readonly name=" . $tastes . ">\n";
>
> echo "this is how you echo a " . $variable . " in a string";
Small correction:
> echo "<textarea rows=\"5\" cols=\"28\" readonly name=" . $tastes . ">\n";
>
> echo "this is how you echo a " . $variable . " in a string";
Need to escape the quotes if you use the same (single or double) type of quote
for your HTML as you do for your PHP code.
Or... (double quotes for PHP, single quotes for HTML)
> echo "<textarea rows='5' cols='28' readonly name=" . $tastes . ">\n";
Or... (single quotes for PHP, double quotes for HTML)
> echo '<textarea rows="5" cols="28" readonly name=' . $tastes . ">\n";
Or... (my personal favorite.. double quotes for PHP and allowing $tastes to be
translated to it's variable by including it within PHP's double quotes)
> echo "<textarea rows=\"5\" cols=\"28\" readonly name=$tastes>\n";
Or another option... (just echo the variable, not the whole line, via PHP)
<textarea rows="5" cols="28" readonly name=<?php echo $tastes; ?>>
(notice the >> on the end.. one is to close the PHP code, the other is to close
the TEXTAREA tag)
-TG
--- End Message ---
--- Begin Message ---
Micah Gersten wrote:
> Nathan Rixham wrote:
>
>> Eduardo wrote:
>>
>>> Hi, I am Eduardo, a new PHP programmer and an old Cobol veteran.
>>> I know that
>>> $tastes=$_POST["tastes"]; moves the content of "tastes" from
>>> <p><textarea rows="5" name="tastes" cols="28"></textarea></p>
>>> to
>>> $tastes
>>>
>>>
>>> How do I move the content of $tastes to X of
>>> echo "<textarea rows="5" cols="28" readonly name=X>\n";
>>> ?
>>>
>>> Thanks, Eduardo
>>>
>>>
>> echo "<textarea rows="5" cols="28" readonly name=" . $tastes . ">\n";
>>
>> echo "this is how you echo a " . $variable . " in a string";
>>
>>
>
> While that is true, that's probably not what the OP wants.
> He's probably looking for:
> echo "<textarea rows="5" cols="28" readonly
> name="tastes">$tastes</textarea>\n";
>
> Thank you,
> Micah Gersten
>
>
As Vicente pointed out, there was a problem with what I posted, so
here's the fixed version:
echo '<textarea rows="5" cols="28" readonly
name="tastes">',$tastes,"</textarea>\n";
Explanation:
Single quotes save from backslashing the quotes.
Commas save the concatenation overhead.
Quotes around the last block since it uses \n which needs doublw quotes to
output.
Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com
--- End Message ---
--- Begin Message ---
Vicente wrote:
>> <p><textarea rows="5" name="tastes" cols="28"></textarea></p>
>>
>
> eps, sorry.. Micah Gersten is right. You will need the echo among
> them.
>
> <textarea rows="5" name="tastes" cols="28"> <? echo $tastes;?> </textarea>
>
>
>
Yep, but you caught the quotes mix-up. :)
Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com
--- End Message ---
--- Begin Message ---
Eduardo don't worry it's the new year hangover. Really you are in a
guru list :)
> Vicente wrote:
>>> <p><textarea rows="5" name="tastes" cols="28"></textarea></p>
>>>
>>
>> eps, sorry.. Micah Gersten is right. You will need the echo among
>> them.
>>
>> <textarea rows="5" name="tastes" cols="28"> <? echo $tastes;?> </textarea>
>>
>>
>>
> Yep, but you caught the quotes mix-up. :)
--- End Message ---
--- Begin Message ---
> How do I move the content of $tastes to X of
> echo "<textarea rows="5" cols="28" readonly name=X>\n";
- with simple quotes (better!):
echo '<textarea rows="5" cols="28" readonly name="'.$tastes.'">';
- on the contrary, you will need a backslash in doublequotes:
echo "<textarea rows=\"5\" cols=\"28\" readonly name=\"$tastes\">";
- also, you can close php brackets before and after putting the php
code inside:
<?
// I break here:
?>
<textarea rows="5" cols="28" readonly name="<? echo $tastes; ?>">
<?
// ...continue
?>
best regards,
--- End Message ---
--- Begin Message ---
> <p><textarea rows="5" name="tastes" cols="28"></textarea></p>
eps, sorry.. Micah Gersten is right. You will need the echo among
them.
<textarea rows="5" name="tastes" cols="28"> <? echo $tastes;?> </textarea>
--- End Message ---
--- Begin Message ---
Michelle Konzack wrote:
Hello Eric,
Am 2009-01-04 14:33:37, schrieb Eric Butera:
On Sun, Jan 4, 2009 at 1:39 PM, Michelle Konzack
<[email protected]> wrote:
----[ '/usr/share/tdphp-vserver/includes/02_functions.inc' ]------------
function fncPushBinary($type='show', $file, $mime='') {
<snip>
$BUFFER=1024;
$HANDLER=fopen($file, r);
$CUR_SIZE=0;
while ( !feof($HANDLER) ) {
$CUR_SIZE+=$BUFFER;
echo fread($HANDLER, $BUFFER);
}
fclose($HANDLER);
fncUserUpdate($user, 'downloads', $file, $CUR_SIZE, $FSIZE);
exit();
<snip>
}
function fncUserUpdate($user, $type, $file, $cur_size, $file_size) {
echo "What The Hell Is Going On Here?\n";
$HANDLER=fopen('/tmp/fncUserUpdate.log', a);
$DATE=date("r");
fwrite($HANDLER, "$DATE $user $file $cur_size $file_size\n");
fclose($HANDLER);
}
------------------------------------------------------------------------
Maybe a combination of ignore_user_abort & connection_status will get
you what you need. This way the user doesn't make the script die, but
you can keep checking to make sure the connection is active. If not,
update that db and exit out. I've never attempted anything like this,
so I don't really have any concrete answers for you.
Since I have encountered that fncUserUpdate() is writing the Test-Logfile
(even with wrong value) I am now puzzeling arround, because I was
thinking, if I am in the loop
while ( !feof($HANDLER) ) {
$CUR_SIZE+=$BUFFER;
echo fread($HANDLER, $BUFFER);
}
and the user intreeupt the transfer, the script would never reach
fncUserUpdate($user, 'downloads', $file, $CUR_SIZE, $FSIZE);
which WAS writing the Test-Logfile while beeing interrupted...
I have checked with phpsysinfo() but there are no settings like
ignore_user_abort
and
connection_status
The above two are functions, not settings.
Here are the links:
http://us.php.net/ignore_user_abort
http://us.php.net/connection_status
<SNIP>
function fncPushBinary($type='show', $file, $mime='') {
ignore_user_abort();
$BUFFER=1024;
$HANDLER=fopen($file, r);
$CUR_SIZE=0;
while ( !feof($HANDLER) ) {
# Check to see if the connection been aborted, or if it timed out.
# Plus, record the reason it was disconnected.
if ( ( $reason = connection_status() ) != CONNECTION_NORMAL ) {
RecordDownloadAmount($CUR_SIZE, $reason);
exit;
}
$CUR_SIZE+=$BUFFER;
echo fread($HANDLER, $BUFFER);
}
fclose($HANDLER);
fncUserUpdate($user, 'downloads', $file, $CUR_SIZE, $FSIZE);
exit();
}
</SNIP>
Something like the above should do the trick. Just create a function
called RecordDownloadAmount() (call it whatever you want really) and
have it log the information that you want stored about the download,
then kill the script. should be that simple really...
Not I have replaced the fncUserUpdate() with the original function for
the PostgreSQL and MySQL database and it is just executed and the script
run up to the end... weird!
Thanks, Greetings and nice Day/Evening
Michelle Konzack
Systemadministrator
24V Electronic Engineer
Tamay Dogan Network
Debian GNU/Linux Consultant
--- End Message ---
--- Begin Message ---
Hello everybody,
I am running a real estate site where I would like to enable bulk upload
via real estate software that exports an xml file into an ftp account.
In order to give every user unique access I would need to generate
individual ftp name and passwords for each member. I can not see how
this should work. My portal is written in PHP 4.x and there every
members loges in with a unique ID. The FTP Server runns on the same
linux machine. How could I generate users for this FTP server with php,
for example on sign up?
Thank you for any help on this.
Best regards,
Merlin
--- End Message ---