php-general Digest 27 Jul 2003 09:19:10 -0000 Issue 2200

Topics (messages 157032 through 157057):

Is their a flash and php mailing list?
        157032 by: Dan J. Rychlik
        157039 by: zerof

Re: Half solved...............what the @#%# is PHPSESSID?
        157033 by: John W. Holmes

Changing Bytes to KB, to megs, to gigs.
        157034 by: Philip J. Newman
        157035 by: Matthew A. Blasinski
        157036 by: Curt Zirzow
        157037 by: Curt Zirzow
        157043 by: Josh Sneaker

FTP - Can't build data connection
        157038 by: Suhas Pharkute
        157040 by: Andrew Brampton

Help with Apache
        157041 by: Corey Edwards . Dreamstar Computer Software
        157042 by: Curt Zirzow
        157044 by: Mark Charette

Re: /n not working
        157045 by: DvDmanDT

OOP, PHP4 & PHP5
        157046 by: Mike Brum
        157047 by: Greg Beaver
        157048 by: John W. Holmes

Re: how to make a global scope array
        157049 by: Jack Lee

Read values from Text Area Box
        157050 by: KEN - 2mediaZone
        157051 by: Tom Rogers

Re: Which templates to use??
        157052 by: Adrian Teasdale

replacing & but not special chars
        157053 by: Shawn McKenzie
        157054 by: Andrew Brampton

pdf problem
        157055 by: Denis L. Menezes
        157057 by: Curt Zirzow

Set Cookie in PHP and call with Perl
        157056 by: TWSC HQ

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 ---
Is their a flash and php mailing list? or PHP for Flash mailing list?

--- End Message ---
--- Begin Message ---
forums.macromedia.com
-----
zerof
-----
Is their a flash and php mailing list? or PHP for Flash mailing list?




--- End Message ---
--- Begin Message --- Ryan A wrote:
Hey John,
I dont think its the browser because I have tried this with opera 6,opera 7,
IE and NN with the same results...
But when i checked the phpinfo() it says that cookies are enabled....Do you
think its worth it to search and replace each Location header with .SID?

Well, if SID has a value, that means the session cookie could not be set. Plain and simple.


--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





--- End Message ---
--- Begin Message ---
My goal is to input the amount of Bytes used by a user as $inputbox and
calculate how many kbs,megs,gigs along with $cost for the price per meg.

<?

$inputbox = "414478244";

// PROCESS DATA
$kbs = $inputbox/1024;
 $megs = $kbs/1024;
 $gigs = $megs/1024;

// CALC COST OF MEGS
cost = $megs * 0.05;

// OUT PUT DATA.
echo"<b>$inputbox bytes = </b><br>$kbs kb.<br>$megs meg @ $0.05c per Meg =
\$$cost<br>$gigs gig.<br><br>";

?>

This is what I get outputted.

414478244 bytes =
404763.910156 kb.
395.277256012 meg @ $0.05c per Meg = $19.7638628006
0.386012945324 gig.

Questions?
1. Should I be dividing by 1024 or 1000? This was passed to me by word of
mouth ...
2. Any way of rounding to 2 or 3 digests after the decimal point.
3. to remove any , from the inputted string.

/ Josh



--- End Message ---
--- Begin Message --- Philip J. Newman wrote:
My goal is to input the amount of Bytes used by a user as $inputbox and
calculate how many kbs,megs,gigs along with $cost for the price per meg.
<snip>

Questions?
1. Should I be dividing by 1024 or 1000? This was passed to me by word of
mouth ...
2. Any way of rounding to 2 or 3 digests after the decimal point.
3. to remove any , from the inputted string.


1) 1024 is more correct, so, use it unless what you're given was (incorrectly) calculated with 1000.


2) round($number, 2) - http://us4.php.net/manual/en/function.round.php

3) Use a search and replace (regular expression) to replace commas with empty strings. ereg_replace("," "", $string) - http://us4.php.net/manual/en/function.ereg-replace.php

HTH,

--
Matt Blasinski (mbv)
Internet Infrastructure Applications Technology
Division of Information Technology
3121 Computer Science and Statistics
1210 West Dayton Street
Madison WI 53706
Work (608) 262-2286
Cell (608) 206-4098


--- End Message ---
--- Begin Message ---
* Thus wrote Philip J. Newman ([EMAIL PROTECTED]):
> My goal is to input the amount of Bytes used by a user as $inputbox and
> calculate how many kbs,megs,gigs along with $cost for the price per meg.
> 
> <?
> 
> $inputbox = "414478244";
> 
> // PROCESS DATA
> $kbs = $inputbox/1024;
>  $megs = $kbs/1024;
>  $gigs = $megs/1024;
> 
> // CALC COST OF MEGS
> cost = $megs * 0.05;
> 
> // OUT PUT DATA.
> echo"<b>$inputbox bytes = </b><br>$kbs kb.<br>$megs meg @ $0.05c per Meg =
> \$$cost<br>$gigs gig.<br><br>";
> 
> ?>
> 
> This is what I get outputted.
> 
> 414478244 bytes =
> 404763.910156 kb.
> 395.277256012 meg @ $0.05c per Meg = $19.7638628006
> 0.386012945324 gig.
> 
> Questions?
> 1. Should I be dividing by 1024 or 1000? This was passed to me by word of
> mouth ...

Use 1024, only marketers seem to be able to  get away with using
1000.

> 2. Any way of rounding to 2 or 3 digests after the decimal point.
see round() and number_format() in the manual.

> 3. to remove any , from the inputted string.
see str_replace()

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
* Thus wrote Matthew A. Blasinski ([EMAIL PROTECTED]):
> Philip J. Newman wrote:
> >My goal is to input the amount of Bytes used by a user as $inputbox and
> >calculate how many kbs,megs,gigs along with $cost for the price per meg.
> 
> [...]
> 
> 3) Use a search and replace (regular expression) to replace commas with 
> empty strings. ereg_replace("," "", $string) - 
> http://us4.php.net/manual/en/function.ereg-replace.php

to go further with this you could make sure they enter a valid
number:

$string = ereg_replace("[^0-9.]", "", $string);



Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
Thanks, that seems to work very well (o;

/ Josh

----- Original Message -----
From: "Curt Zirzow" <[EMAIL PROTECTED]>
To: "PHP" <[EMAIL PROTECTED]>
Sent: Sunday, July 27, 2003 10:17 AM
Subject: Re: [PHP] Changing Bytes to KB, to megs, to gigs.


> * Thus wrote Matthew A. Blasinski ([EMAIL PROTECTED]):
> > Philip J. Newman wrote:
> > >My goal is to input the amount of Bytes used by a user as $inputbox and
> > >calculate how many kbs,megs,gigs along with $cost for the price per
meg.
> >
> > [...]
> >
> > 3) Use a search and replace (regular expression) to replace commas with
> > empty strings. ereg_replace("," "", $string) -
> > http://us4.php.net/manual/en/function.ereg-replace.php
>
> to go further with this you could make sure they enter a valid
> number:
>
> $string = ereg_replace("[^0-9.]", "", $string);
>
>
>
> Curt
> --
> "I used to think I was indecisive, but now I'm not so sure."
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



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

I am writing a FTP application. When I upload a file I am getting following error,

Warning: ftp_put(): Can't build data connection: Connection refused.

There is no error for connection/login to ftp site.

can any one help?

Thanks,
Suhas


_________________________________

Encrypt your PHP code for FREE at

http://encphp.sspsoft.com

_________________________________

--- End Message ---
--- Begin Message ---
This would happen when a incoming or a outgoing port 20 (FTP Data)
connection can't be made.

I don't know how PHP ftp functions work but normally the FTP client makes a
outgoing connection on port 21, and then the FTP Server makes a incoming
connection from port 20 when any kind of data is sent (ie directory
listings, or files)....

So I'm guessing that the web server that you are running ftp_put on doesn't
allow incoming connections...
You can try getting around this by setting PHP to use Passive mode, which
makes the FTP client connection out to port 20 on the FTP server. A quick
look at the manual says that you should use ftp_pasv to make that happen.

Hope this helps
Andrew
----- Original Message -----
From: "Suhas Pharkute" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, July 26, 2003 11:29 PM
Subject: [PHP] FTP - Can't build data connection


Hi

I am writing a FTP application. When I upload a file I am getting following
error,

Warning: ftp_put(): Can't build data connection: Connection refused.

There is no error for connection/login to ftp site.

can any one help?

Thanks,
Suhas


_________________________________

Encrypt your PHP code for FREE at

http://encphp.sspsoft.com

_________________________________


--- End Message ---
--- Begin Message ---
I finally set up an Apache Web Server. I didn't realize you needed that to
run php until now.
 
 Now, I have another question.
I have it installed, but when I run a PHP script, it says it can't be found.
Even when I am running the apache server. And the apache server seems to be
running fine.

--- End Message ---
--- Begin Message ---
* Thus wrote Corey Edwards @ Dreamstar Computer Software ([EMAIL PROTECTED]):
> I finally set up an Apache Web Server. I didn't realize you needed that to
> run php until now.
>  
>  Now, I have another question.
> I have it installed, but when I run a PHP script, it says it can't be found.
> Even when I am running the apache server. And the apache server seems to be
> running fine.

No one is going to be able to help you since you have provided not
enough information.

Did you read the installation for your paticular setup:
  http://php.net/installation

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: Corey Edwards @ Dreamstar Computer Software
>
> I finally set up an Apache Web Server. I didn't realize you needed that to
> run php until now.

That's only true if you need to serve Web pages; php runs fine from the
command line ...




--- End Message ---
--- Begin Message ---
I must suggest to just add like

    header("Content-Type: text/plain"); // Don't use HTML

To the top of examples like that...
-- 
// DvDmanDT
MSN: [EMAIL PROTECTED]
Mail: [EMAIL PROTECTED]
"Curt Zirzow" <[EMAIL PROTECTED]> skrev i meddelandet
news:[EMAIL PROTECTED]
> * Thus wrote John W. Holmes ([EMAIL PROTECTED]):
> > Thomas Hochstetter wrote:
> > >
> > >$text = "The quick brown fox jumped over the lazy dog.";
> > >$newtext = wordwrap($text, 20);
> > >
> > >echo "$newtext\n";
> > > [...]
> >
> > HTML does not render newlines. You need to use <br />. View the source
> > of this code in your browser and you'll see everything is on it's own
line.
> >
>
> Yes the documentation is a little misleading. I'm in the process of
> getting that changed in the documentation.
>
> Curt
> -- 
> "I used to think I was indecisive, but now I'm not so sure."



--- End Message ---
--- Begin Message ---
I've been using PHP for a few years now and I'm quite familiar and
comfortable with it. 

I'd like to start to seriously do some OOP coding and "take things to
the next level". But as I understand it, PHP5 is going to make quite a
few changes/improvements to PHP4's current handling of OOP.

Given that the PHP5 beta has been out for approx. 1 month, do you think
it makes sense to try to get into OOP with PHP4 right now when things
could change in a fairly short while (not sure how long it'll be until
PHP5 is released) and then have to re-learn certain aspects of OOP after
getting comfortable with it? Or do you think that the change from 4 to 5
won't really be that big of a deal?

I know that many people ask OOP-related questions a lot on the board,
but I was just wondering what everyone thought of the jump from 4 to 5
and about trying to start learning OOP *right now*.

Thanks

-M



--- End Message ---
--- Begin Message --- Hi Mike,

The short answer:

Yes.

The long answer:

PHP 5 only adds functionality to PHP 4, it is backwards compatible, so start with PHP 4, and PHP 5 will be easy.

Greg

Mike Brum wrote:
I've been using PHP for a few years now and I'm quite familiar and
comfortable with it.


I'd like to start to seriously do some OOP coding and "take things to
the next level". But as I understand it, PHP5 is going to make quite a
few changes/improvements to PHP4's current handling of OOP.

Given that the PHP5 beta has been out for approx. 1 month, do you think
it makes sense to try to get into OOP with PHP4 right now when things
could change in a fairly short while (not sure how long it'll be until
PHP5 is released) and then have to re-learn certain aspects of OOP after
getting comfortable with it? Or do you think that the change from 4 to 5
won't really be that big of a deal?

I know that many people ask OOP-related questions a lot on the board,
but I was just wondering what everyone thought of the jump from 4 to 5
and about trying to start learning OOP *right now*.

Thanks

-M





--- End Message ---
--- Begin Message --- Mike Brum wrote:
I'd like to start to seriously do some OOP coding and "take things to
the next level". But as I understand it, PHP5 is going to make quite a
few changes/improvements to PHP4's current handling of OOP.

Given that the PHP5 beta has been out for approx. 1 month, do you think
it makes sense to try to get into OOP with PHP4 right now when things
could change in a fairly short while (not sure how long it'll be until
PHP5 is released) and then have to re-learn certain aspects of OOP after
getting comfortable with it? Or do you think that the change from 4 to 5
won't really be that big of a deal?

I know that many people ask OOP-related questions a lot on the board,
but I was just wondering what everyone thought of the jump from 4 to 5
and about trying to start learning OOP *right now*.

I'd say get a good book on OO thinking/methodology and read that. Do a little practicing in PHP4, but I'd wait until PHP5 to really get into it. PHP5 is supposed to have a lot more OO features.


My $0.02, of course. I just got "The Object Oriented Though Process" by SAMS from someone through Amazon. Looks to be a good book.

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals – www.phparch.com





--- End Message ---
--- Begin Message ---
Thank you very much!

"David Nicholson" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Hello,

This is a reply to an e-mail that you wrote on Sat, 26 Jul 2003 at
00:50, lines prefixed by '>' were originally written by you.
> Ouch!
> Sometimes I wish global didn't exist

Yes, it can be better to pass in a variable (by reference if you need
to write to it from within a function and not have it as the value
that you return), e.g.

function doSomething(&$a){
    $a = 20;
    return true; // to signify success
}

$a = 10;
doSomething($a);
echo $a; // prints 20


-- 
phpmachine :: The quick and easy to use service providing you with
professionally developed PHP scripts :: http://www.phpmachine.com/

          Professional Web Development by David Nicholson
                    http://www.djnicholson.com/

    QuizSender.com - How well do your friends actually know you?
                     http://www.quizsender.com/
                    (developed entirely in PHP)



--- End Message ---
--- Begin Message ---
Hi, there.

I'm trying to find out how to get multiple values from text area box
<textarea></textarea>.


Values are like this.

aaa\n
bbb\n
ccc\n
ddd\n
eee\n

I need to take "\n" from each value and put all the values to array.


Please advise me if anyone knows about this.


Sincerely,


KEN

--- End Message ---
--- Begin Message ---
Hi,

Sunday, July 27, 2003, 3:04:56 PM, you wrote:
K2> Hi, there.

K2> I'm trying to find out how to get multiple values from text area box
K2> <textarea></textarea>.


K2> Values are like this.

K2> aaa\n
K2> bbb\n
K2> ccc\n
K2> ddd\n
K2> eee\n

K2> I need to take "\n" from each value and put all the values to array.


K2> Please advise me if anyone knows about this.


K2> Sincerely,


K2> KEN

You could try

$array = explode("\n",$textareastring);

-- 
regards,
Tom


--- End Message ---
--- Begin Message ---
Hi there Binay

Have a look at http://smarty.php.net - this is a very good templating
engine.

You could also consider creating your own if you have specific needs. We
created our own pre-parser (built in PHP but soon to be ported to an Apache
module) that works really well for us

Best regards

Adrian
sourceguardian.com


> -----Original Message-----
> From: Binay Agarwal [mailto:[EMAIL PROTECTED]
> Sent: 26 July 2003 01:04
> To: [EMAIL PROTECTED]
> Subject: [PHP] Which templates to use??
>
>
> Hi all!
>
>         As a php developer i need to know how can i separate my
> "business logic tier" with "presentation". I mean wht all
> different kinds of php Templates are available and which one to
> go for better efficiency and speed? Where can i find the
> resources. Please help me out.
>
> Thanks in advance
>
> Binay
>


--- End Message ---
--- Begin Message ---
I have some URLs in hrefs that have an &.  This does not validate HTM4.01
transitional, so I want to replace them with &amp;

So I buffer the output and do a replace, but suppose there is already an
&amp; then I get &amp;amp; or if I have anything else like &quot; then I get
&amp;quot;

Any ideas on how to do this the right way???

Thanks!
Shawn



--- End Message ---
--- Begin Message ---
How about you decode the string, and then encode it like so:
$decode = html_entity_decode($input);
$output = htmlentities($decode);

If you have the string
ab&amp;something&blah
the decode will turn that into
ab&something&blah
and then encode it into
ab&amp;something&amp;blah

This can run into problems, but they will be just the same problems you
would receive with any other method... The problem I speak of is when your
input string is "something&amp;" and &amp; isn't a HTML Entity but the
proper string just so happened to have a & in it just before the amp... In
that case the amp; would be incorrectly removed... However the chances of
having a string that matches a HTML entity with a "bad" & placed in front of
it are so high that you shouldn't worry (and you did mention it was a URL,
so as far as I know ; can't appear in a valid URL, so I don't think you
should worry at all :))... And if you are worrying then any method you chose
will have this problem and you should do the task by hand :)

Hope this helps
Andrew

----- Original Message -----
From: "Shawn McKenzie" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, July 27, 2003 8:36 AM
Subject: [PHP] replacing & but not special chars


> I have some URLs in hrefs that have an &.  This does not validate HTM4.01
> transitional, so I want to replace them with &amp;
>
> So I buffer the output and do a replace, but suppose there is already an
> &amp; then I get &amp;amp; or if I have anything else like &quot; then I
get
> &amp;quot;
>
> Any ideas on how to do this the right way???
>
> Thanks!
> Shawn
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--- End Message ---
--- Begin Message ---
Hello friends.

I was checking for creation of pdf document on the
server. But i was getting "Call to undefined function:
pdf_new() in /home/andsales/public_html/sap/getpdf.php
on line 2".

Can anyone te;ll me a solution?
Is there some problem with compilation of PHP
with PDFLIB libraries?

Thanks
Denis



--- End Message ---
--- Begin Message ---
* Thus wrote Denis L. Menezes ([EMAIL PROTECTED]):
> Hello friends.
> 
> I was checking for creation of pdf document on the
> server. But i was getting "Call to undefined function:
> pdf_new() in /home/andsales/public_html/sap/getpdf.php
> on line 2".
> 
> Can anyone te;ll me a solution?
> Is there some problem with compilation of PHP
> with PDFLIB libraries?

It seems that your php isn't compiled with pdf.

Curt
-- 
"I used to think I was indecisive, but now I'm not so sure."

--- End Message ---
--- Begin Message ---
Hi there - 

Is this possible :
How do i call the cookie value (surname) with Perl if it was set with PHP?

SAMPLE:

PHP Cookie set:

<? 
setcookie("surname", "mc Seveney", time()+31536000, "/","",0); 
?>

Need to call this cookie with a .pl extension file (perl)

thanks

August 


--- End Message ---

Reply via email to