php-general Digest 24 Nov 2004 14:14:10 -0000 Issue 3131
Topics (messages 202740 through 202754):
Why $a +1 is not 02 ??
202740 by: Labunski
202741 by: Ben Ramsey
202746 by: Mailit, LLC
Re: Lost Variables
202742 by: Jason Wong
Re: submitting two forms on one page
202743 by: Marek Kilimajer
remove first character in text file
202744 by: Dustin Krysak
202745 by: Mike
202747 by: Dustin Krysak
202748 by: Robinson, Matthew
Dynamic Class Name Assignments
202749 by: bob pilly
202751 by: PHP Mailingliste Tarta
Generating pdf file on the fly
202750 by: pt2002
RM file - play time
202752 by: Alexander Kleshchevnikov
PHP info: MySQL client API version: 3.23?
202753 by: Olaf van der Spek
PHP spell checker for Textarea
202754 by: Angelo Zanetti
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 ---
Hello,
I have small problem..
$a = 01;
echo $a+1;
//this will display 2, instead of 02.
How to get 02?
thanks.
Lab.
--- End Message ---
--- Begin Message ---
Labunski wrote:
Hello,
I have small problem..
$a = 01;
echo $a+1;
//this will display 2, instead of 02.
How to get 02?
thanks.
Lab.
You need to understand how PHP treats integers. It can never start an
integer with a zero unless it's an octal or a hexadecimal number. And
PHP will not hesitate to parse a string as an integer. For example, even
if you had $a = "01" (clearly "01" is a string), and then did echo $a+1,
you would still get 2 since "01" will evaluate to the integer 1.
Read more on integers here: http://www.php.net/types.integer
Now, to answer your question, just use the str_pad() function:
http://www.php.net/str_pad
Looks like this:
$a = 1;
echo str_pad($a+1, 2, "0", STR_PAD_LEFT);
This will output "02" as desired.
--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com
---------------------------------------------------
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---------------------------------------------------
--- End Message ---
--- Begin Message ---
use printf( "%02d", $a + 1 )
or something like that. Should work.
Mario
<p>
Labunski wrote:
Hello,
I have small problem..
$a = 01;
echo $a+1;
//this will display 2, instead of 02.
How to get 02?
thanks.
Lab.
--- End Message ---
--- Begin Message ---
On Wednesday 24 November 2004 04:52, Monique Verrier wrote:
> I am using the general strategy suggested by Jay (thanks, Jay) to process
> my form in another procedure. It's listed below. In my processStuff.php
> program, I use the following code:
>
> $attributes = array();
> $attributes = array_merge($attributes,$HTTP_POST_VARS, $HTTP_GET_VARS);
> extract($attributes, EXTR_PREFIX_SAME, "this");
>
> I want to load my numerous post variables into regular memory variables (or
> whatever the php nomenclature is) -- e.g. $_POST['action'] becomes $action.
> It doesn't seem to working according to the manual.
How is it not working? What does var_dump($attributes) show?
> I list my $HTTP_SESSION_VARS, there are none.
Is this related to the above? $HTTP_SESSION_VARS would normally be empty
unless you start a session and register some session variables.
> I would appreciate anyone taking the time to explain to me how this works.
> Either it's stupid or I'm stupid. I'm figuring it's me.
1) Usually there is little point putting the request variables
($HTTP_POST_VARS, $HTTP_GET_VARS, $_GET, $_POST) into the local namespace.
Just use them directly as you have here:
> switch ($_POST['action']){
> case "Add Record":
> ...do stuff...
2) If you really must do (1) then instead of:
extract($attributes, EXTR_PREFIX_SAME, "this");
you should probably use this:
extract($attributes, EXTR_PREFIX_ALL, "this");
that way you'll know that variables prefixed with 'this' came from
$HTTP_POST_VARS, $HTTP_GET_VARS. BTW why are you processing $HTTP_GET_VARS?
You're using "POST" for your form.
3) To save confusion use only the new "superglobals" ($_POST, $_GET etc) OR
only the old, deprecated request variables ($HTTP_POST_VARS, $HTTP_GET_VARS).
Do not mix the two in the same code. See manual for details.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
BOFH Excuse #248:
Too much radiation coming from the soil.
*/
--- End Message ---
--- Begin Message ---
Adil wrote:
Hey everyone, I'm having issues with a couple of forms that exist on one
page. Basically what I'm trying to do is the following:
Select a client from a dropdown select box(submit inner form). Based on
that, another select menu appears that retrieves a list of projects based on
the client selected. Then you choose a file and upload it(submit the outer
form) which uploads the file and adds the file entry under the client
project table selected in the 2nd dropdown.
The problem is that the outer form works fine, but the inner form that
dynamically retrieves the client project list doesn't refresh the page or
post so the project list never shows up. I've listed some code below.
Forms can't be nested. From your description it looks like the best way
is to use 2 forms, each on a separate page.
Another way is to use a form that posts to itself, but the action is not
taken until a project is selected and a file is uploaded.
--- End Message ---
--- Begin Message ---
Hi there.. I have a text file where I need to remove JUST the first
character in the text file. Can anyone point me to a tutorial?
d
--- End Message ---
--- Begin Message ---
Start with fopen() - http://us2.php.net/manual/en/function.fopen.php
Then use fread() - http://us2.php.net/manual/en/function.fread.php
There's many user-contributed comments that should be of use. The docs are
also quite helpful.
-M
> Hi there.. I have a text file where I need to remove JUST the
> first character in the text file. Can anyone point me to a tutorial?
>
> d
>
--- End Message ---
--- Begin Message ---
Just want to add to this with a little more info....
my text file is a list of email addresses with a "%" separating them.
For example:
[EMAIL PROTECTED]@[EMAIL PROTECTED]
Now sometimes I end up with a "%" at the beginning. For example:
[EMAIL PROTECTED]@[EMAIL PROTECTED]
Or:
[EMAIL PROTECTED]@[EMAIL PROTECTED]
Now that causes me issues else where in the script. So what I need to
do is check if the "%" character exists at the beginning of the file
and remove any if the "%" is there.
ideas?
d
Hi there.. I have a text file where I need to remove JUST the
first character in the text file. Can anyone point me to a tutorial?
d
--- End Message ---
--- Begin Message ---
<?php
$email = '[EMAIL PROTECTED]@[EMAIL PROTECTED]';
$email = preg_replace('/^%%+/','%',$email);
print "$email";
?>
-----Original Message-----
From: Dustin Krysak [mailto:[EMAIL PROTECTED]
Sent: 24 November 2004 09:53
To: PHP
Subject: Re: [PHP] remove first character in text file
Just want to add to this with a little more info....
my text file is a list of email addresses with a "%" separating them.
For example:
[EMAIL PROTECTED]@[EMAIL PROTECTED]
Now sometimes I end up with a "%" at the beginning. For example:
[EMAIL PROTECTED]@[EMAIL PROTECTED]
Or:
[EMAIL PROTECTED]@[EMAIL PROTECTED]
Now that causes me issues else where in the script. So what I need to do
is check if the "%" character exists at the beginning of the file and
remove any if the "%" is there.
ideas?
d
>
>> Hi there.. I have a text file where I need to remove JUST the first
>> character in the text file. Can anyone point me to a tutorial?
>>
>> d
>>
>
________________________________________________________________________
This message has been checked for all known viruses by the
CitC Virus Scanning Service powered by SkyLabs. For further information visit
http://www.citc.it
___
--- End Message ---
--- Begin Message ---
Hi All, im new to classes in PHP. Im trying to create
several instances of a very basic class but i want
each name to be based on number values in an array and
im not sure if it is allowed and if so how to do it. I
assume that im not allow to have a var starting with a
number so what i am trying to do is add the word case
to the front of the class instance name so i would
have $case100,$case101 etc. Im am using PHP 5.02.
Heres my code
<?php
class Test
{
//members
var $caseid,$fee;
function Test($caseid){
$this->caseid=$caseid;
}
function addmember($membername,$value){
$this->$membername=$value;
}
}
$names=array("100","101","102","104");
$numnames=count($names);
for($i=0;$i<$numnames;$i++){
*** below is the syntax im missing ***
$case.$names[$i] = new Test($names[$i]);
}
var_dump($case100);
?>
Thanks for any help in advance!
Cheers
Bob Pilford
___________________________________________________________
ALL-NEW Yahoo! Messenger - all new features - even more fun!
http://uk.messenger.yahoo.com
--- End Message ---
--- Begin Message ---
Guess its something like
$pref = "case";
for($i=0;$i<$numnames;$i++){
${$pref.$names[$i]} = new Test($name[$i]);
}
__
Stefan
> -----Urspr�ngliche Nachricht-----
> Von: bob pilly [mailto:[EMAIL PROTECTED]
> Gesendet: Mittwoch, 24. November 2004 12:52
> An: [EMAIL PROTECTED]
> Betreff: [PHP] Dynamic Class Name Assignments
>
> Hi All, im new to classes in PHP. Im trying to create
> several instances of a very basic class but i want
> each name to be based on number values in an array and
> im not sure if it is allowed and if so how to do it. I
> assume that im not allow to have a var starting with a
> number so what i am trying to do is add the word case
> to the front of the class instance name so i would
> have $case100,$case101 etc. Im am using PHP 5.02.
> Heres my code
>
> <?php
>
> class Test
> {
> //members
> var $caseid,$fee;
>
> function Test($caseid){
> $this->caseid=$caseid;
> }
>
> function addmember($membername,$value){
> $this->$membername=$value;
> }
> }
>
> $names=array("100","101","102","104");
> $numnames=count($names);
> for($i=0;$i<$numnames;$i++){
> *** below is the syntax im missing ***
> $case.$names[$i] = new Test($names[$i]);
> }
> var_dump($case100);
> ?>
>
> Thanks for any help in advance!
>
> Cheers
>
> Bob Pilford
>
>
>
>
>
> ___________________________________________________________
> ALL-NEW Yahoo! Messenger - all new features - even more fun!
> http://uk.messenger.yahoo.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi
I use fpdf to generate pdf on the fly. It should display pdf in the browser
and it's ok withou mod_gzip.
Actually the problem is mod_gzip.
It seems IE doesn't work very well with this combination. No problems with
Firefox.
Anyone had this problem too?
Greetings
pt2002
--- End Message ---
--- Begin Message ---
Can I get the information about paly time of the RM file by PHP?
Thanks.
--- End Message ---
--- Begin Message ---
In the phpinfo() output, the MySQL client API version is shown as 3.23.49.
Shouldn't this be upgraded to 4.1 (generally available/stable)?
--- End Message ---
--- Begin Message ---
HI all,
Does anyone know of a decent spell checker for an HTML textarea?
Thanks in advance
Angelo
--------------------------------------------------------------------
Disclaimer
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is
intended for the attention and use only of the addressee.
Should you have received this e-mail in error, please delete
and destroy it and any attachments thereto immediately.
Under no circumstances will the Cape Technikon or the sender
of this e-mail be liable to any party for any direct, indirect,
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911
--- End Message ---