php-general Digest 12 Jun 2009 07:34:34 -0000 Issue 6171

Topics (messages 293952 through 293968):

Re: [Bulk] Re: [PHP] Why [?php while (true) { sleep(5); } ?] dies on CLI?
        293952 by: Robert Cummings

Field type for american money
        293953 by: revDAVE
        293954 by: Daniel Brown
        293955 by: Shawn McKenzie
        293956 by: Waynn Lue
        293957 by: Shawn McKenzie
        293959 by: Robert Cummings
        293961 by: Waynn Lue
        293962 by: Shawn McKenzie

CURL intermittant problem
        293958 by: ioannes.btinternet.com
        293960 by: Daniel Brown
        293963 by: Martin Scotta

Beginner at writting a PHP Wrapper for C++ libraries
        293964 by: Eric A. Boney

Dynamic Titles
        293965 by: Austin Caudill
        293968 by: David Robley

Re: Same Page, Fundamentally Different Behavior OR is Firefox broken?
        293966 by: Manuel C.
        293967 by: Nitsan Bin-Nun

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 ---
Jean-Pierre Arneodo wrote:
Ashley Sheridan a écrit :
On Thu, 2009-06-11 at 10:47 +0000, Jean-Pierre Arneodo wrote:
Hi!
I'm stuck.
I don't understand why the php CLI dies after 3 hours in my script.
Any idea to solve?
Thanks


PHP 5.2.9-0.dotdeb.2 with Suhosin-Patch 0.9.7 (cli) (built: Apr 7 2009 20:06:36) Linux ubuntu 2.6.24-19-server #1 SMP Wed Jun 18 14:44:47 UTC 2008 x86_64 GNU/Linux

Conf [php.ini]
max_execution_time=0

<?php
while (true) {
        sleep(5);
}
?>


The while loop will continue executing until its condition is false. As
you've got a boolean true as the condition, it will never end.

Thanks
Ash
www.ashleysheridan.co.uk
I don't want to stop, but the process dies.

I've tried the same loop with bash interpretor.
Same result, it seems to be a ubuntu problem, not a php problem.

Open up a shell... type the following into it:

ulimit -a

What do you see?

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--- End Message ---
--- Begin Message ---
Php - MySQL - newbie question

- Field type for american money - int(11) seems to work fine

- but also I tried decimal(10,2)

Is one a better choice than another for american money usage?


--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]




--- End Message ---
--- Begin Message ---
On Thu, Jun 11, 2009 at 16:08, revDAVE<[email protected]> wrote:
> Php - MySQL - newbie question
>
> - Field type for american money - int(11) seems to work fine
>
> - but also I tried decimal(10,2)
>
> Is one a better choice than another for american money usage?

    For PHP, check out money_format(), number_format(), and sprintf()
with `%0.2f` or similar.  For MySQL, ask on the MySQL list.  ;-P

-- 
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000

--- End Message ---
--- Begin Message ---
revDAVE wrote:
> Php - MySQL - newbie question
> 
> - Field type for american money - int(11) seems to work fine
> 
> - but also I tried decimal(10,2)
> 
> Is one a better choice than another for american money usage?
> 
> 
> --
> Thanks - RevDave
> Cool @ hosting4days . com
> [db-lists 09]
> 
> 
> 

If you are only interested in round dollar amounts then int should work
fine ;-)  If you expect any fractions of a dollar (as I suspect you
will), such as 19.95 then use decimal.

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
For mysql, it's better to use int and then store it in cents (or
micros) so you can use all integer operations instead of float ones.

On 6/11/09, Shawn McKenzie <[email protected]> wrote:
> revDAVE wrote:
>> Php - MySQL - newbie question
>>
>> - Field type for american money - int(11) seems to work fine
>>
>> - but also I tried decimal(10,2)
>>
>> Is one a better choice than another for american money usage?
>>
>>
>> --
>> Thanks - RevDave
>> Cool @ hosting4days . com
>> [db-lists 09]
>>
>>
>>
>
> If you are only interested in round dollar amounts then int should work
> fine ;-)  If you expect any fractions of a dollar (as I suspect you
> will), such as 19.95 then use decimal.
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Waynn Lue wrote:
> For mysql, it's better to use int and then store it in cents (or
> micros) so you can use all integer operations instead of float ones.
> 

To each his own.  Speed or otherwise I don't see a difference between:

$total = 19.95 + 3.99; //shipping

and

$total = 1995 + 399; //shipping

Except with the ints you have to format them for display.


-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
Shawn McKenzie wrote:
Waynn Lue wrote:
For mysql, it's better to use int and then store it in cents (or
micros) so you can use all integer operations instead of float ones.


To each his own.  Speed or otherwise I don't see a difference between:

$total = 19.95 + 3.99; //shipping

and

$total = 1995 + 399; //shipping

Except with the ints you have to format them for display.

You have to format the floats too:

<?php

    $total = 5.55 + 9.35;
    echo $total."\n";

?>

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

--- End Message ---
--- Begin Message ---
>
> Shawn McKenzie wrote:
>
>> Waynn Lue wrote:
>>
>>> For mysql, it's better to use int and then store it in cents (or
>>> micros) so you can use all integer operations instead of float ones.
>>>
>>>
>> To each his own.  Speed or otherwise I don't see a difference between:
>>
>> $total = 19.95 + 3.99; //shipping
>>
>> and
>>
>> $total = 1995 + 399; //shipping
>>
>> Except with the ints you have to format them for display.
>>
>
> You have to format the floats too:
>
> <?php
>
>    $total = 5.55 + 9.35;
>    echo $total."\n";
>
> ?>
>

Oh, I didn't mean speed within PHP, I meant for mysql operations.  I'm not
sure how PHP handles int vs. float operations (though int is usually faster
than float for other languages, isn't it?).

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
> Shawn McKenzie wrote:
>> Waynn Lue wrote:
>>> For mysql, it's better to use int and then store it in cents (or
>>> micros) so you can use all integer operations instead of float ones.
>>>
>>
>> To each his own.  Speed or otherwise I don't see a difference between:
>>
>> $total = 19.95 + 3.99; //shipping
>>
>> and
>>
>> $total = 1995 + 399; //shipping
>>
>> Except with the ints you have to format them for display.
> 
> You have to format the floats too:
> 
> <?php
> 
>     $total = 5.55 + 9.35;
>     echo $total."\n";
> 
> ?>
> 
> Cheers,
> Rob.

Yeah, yeah, yeah...

I guess what I meant to say was that I had never really considered using
ints :-)

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message --- I have been having problems with a curl script which works normally with many different URLs but had a particular intermittant problem with a url in the following format: http://10.20.30.40/00000001/032/023112/filename.phtml?param1=paramvalue1&param2=paramvalue2 etc etc.

The unusual thing about this URL is that is starts with an IP address. I got a lot of failures to connect, so tried a different way to connect as all I need is the page as a string:

According to php.net, the function 'file_get_contents()' should work if allow_url_fopen is set to TRUE for the PHP installation. 'allow_url_fopen' is set to 1 in my php.ini file.

http://php.net/file_get_contents
http://php.net/allow_url_fopen

However, 'file_get_contents' also fails to connect to this particular URL. It gives:

"failed to open stream: Connection timed out in */home/shortsta/public_html/live48_test.php* on line *75*

*Warning*: feof(): supplied argument is not a valid stream resource in */home/mysite/public_html/testpage.php* on line *79*"

The target URL works perfectly and quicly if put directly into the browser URL line.

Do you know of any other reasons for problems with such a connection?

John

--- End Message ---
--- Begin Message ---
On Thu, Jun 11, 2009 at 19:07,
[email protected]<[email protected]> wrote:
>
> The target URL works perfectly and quicly if put directly into the browser
> URL line.
>
> Do you know of any other reasons for problems with such a connection?

    Is the script being run located on the same system as which you're
using the browser to (successfully) connect to the target host?  If
not, check to see if there's a network issue - a downed or improperly
bound interface, SELinux restrictions, blacklisted by the remote
machine, etc. - on the server on which the script it hosted.  In
addition, as simple and obvious as it is, if it's a private network,
make sure the machine on which the script is hosted is within the same
network as the target machine.

-- 
</Daniel P. Brown>
[email protected] || [email protected]
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000

--- End Message ---
--- Begin Message ---
It looks like a connection problem,

You has to make sure php can connect to the IP

<?php
   echo exec( 'ping 10.20.30.40' );
?>

You can remove the IP from the source, just add an entry in the /etc/hosts
file

Mrtn

On Thu, Jun 11, 2009 at 8:14 PM, Daniel Brown <[email protected]> wrote:

> On Thu, Jun 11, 2009 at 19:07,
> [email protected]<[email protected]> wrote:
> >
> > The target URL works perfectly and quicly if put directly into the
> browser
> > URL line.
> >
> > Do you know of any other reasons for problems with such a connection?
>
>     Is the script being run located on the same system as which you're
> using the browser to (successfully) connect to the target host?  If
> not, check to see if there's a network issue - a downed or improperly
> bound interface, SELinux restrictions, blacklisted by the remote
> machine, etc. - on the server on which the script it hosted.  In
> addition, as simple and obvious as it is, if it's a private network,
> make sure the machine on which the script is hosted is within the same
> network as the target machine.
>
> --
> </Daniel P. Brown>
> [email protected] || [email protected]
> http://www.parasane.net/ || http://www.pilotpig.net/
> 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW10000
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Martin Scotta

--- End Message ---
--- Begin Message ---
I am just beginning my foray into writing my own wrapper for a C++ library 
that maintained by someone else. I have ordered Sara Golemon's book "Extending 
and Embedding PHP" which should arrive in the next week or so, but until then 
I had a couple of questions that I was hoping might be able to be answered 
here. If this is the incorrect list to post this to, please let me know.

Is it possible to use an object file from the C++ library directly in the 
config.m4 file? I attempted to create a symlink to the cpp file that I needed 
for 
my extension but I get a ton of errors when I try to make the extension and I 
am guessing it is because this one cpp file that I need requires a ton of other 
header files.

Second question is, I thought I read somewhere that it was possible to create 
a stand alone extension that did not require the end user to install the .so 
file and then modify the php.ini file and restart the apache server. How can I 
do this with my extension and just call/load the .so file in my script(s) that 
need it?

Thanks in advance.

-Eric Bonney

--- End Message ---
--- Begin Message ---
Hello, im trying to make the CMS system im using more SEO friendly by giving 
each page it's own title. Right now, the system assigns all pages the same 
general title. I would like to use PHP to discertain which page is being viewed 
and in turn, which title should be used.

I have put in the title tags the variable "$title". As for the PHP im using, I 
scripted the following:

$url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";
switch ( $url )
{
    default:
        $title = "Photoshop tutorials, Flash tutorials, and more! Newtuts 
Tutorial Search";
        break;

    case "$config[HTTP_SERVER]help.php" :
        $title = "Newtuts Help";
        break;
}
 
Right now, im getting this error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting 
T_STRING or T_VARIABLE or T_NUM_STRING in 
/home/a7201901/public_html/includes/classes/tutorial.php on line 803 
 
Can someone please help me with this?



Thanks!


      

--- End Message ---
--- Begin Message ---
Austin Caudill wrote:

> Hello, im trying to make the CMS system im using more SEO friendly by
> giving each page it's own title. Right now, the system assigns all pages
> the same general title. I would like to use PHP to discertain which page
> is being viewed and in turn, which title should be used.
> 
> I have put in the title tags the variable "$title". As for the PHP im
> using, I scripted the following:
> 
> $url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";
> switch ( $url )
> {
> default:
> $title = "Photoshop tutorials, Flash tutorials, and more! Newtuts Tutorial
> Search"; break;
> 
> case "$config[HTTP_SERVER]help.php" :
> $title = "Newtuts Help";
> break;
> }
> 
> Right now, im getting this error:
> Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
> T_STRING or T_VARIABLE or T_NUM_STRING in
> /home/a7201901/public_html/includes/classes/tutorial.php on line 803
> 
> Can someone please help me with this?
> 
> 
> 
> Thanks!
I'm guessing that line 803 is

$url = "http://'.$_SERVER['SERVER_NAME']''.$_SERVER['REQUEST_URI']'";

which is full of mismatched quotes :-) Try any of

$url = "http://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}";
$url = "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
$url = 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

Cheers
-- 
David Robley

Life is only as long as you live it.
Today is Pungenday, the 17th day of Confusion in the YOLD 3175. 


--- End Message ---
--- Begin Message ---
Matt Neimeyer a écrit :
I'm at a complete loss... So I'm hoping someone can point me in the
right direction to even start looking.

We have an application written in PHP that lets users send out emails.
The basic process is as follows.

1. Go to "start" screen. (This resets anything currently in process
for the current logged in user)
2. Upload email addresses and other info (Names, etc)
3. Build Email
4. Send

In Step 3 the user can click a "Live Preview" button to see what the
email will look like with the merged data.

Here's the problem,  this works fine in all versions of IE, versions
1.5 or less of FireFox and versions 3 or less of Safari. However,
starting in FireFox 2, and now Safari 4, when you get to step four OR
click the live preview button in step three there is no more data in
the merge. In those browsers the system is acting like the end user
went BACK to the start page (in another window?) and reinitialized all
the data.

I immediately thought it might be pre-fetching so I tried using the
system before and after toggling the network.prefetch-next setting in
about:config with FireFox 2.0.0.20 and restarting the browser. No
luck. So I added code to my reset function to email me the output of
phpinfo() when the reset function is called. Using IE I get 1
notification. Using FF I get two notifications. This reinforces my
theory that FireFox is prefetching the menu item to start a new
mailing (just an <a> link...) from the top of the composer page. Even
still... I've disabled prefetch so it SHOULDN'T even be considering
those links right? I've also tried adding artificial
"?now=<timestamp>" fakes to the end of all menu links since I read
somewhere (don't remember where) that FireFox only prefetches pages
with no query section in the address.

Has anyone run into this behavior before? Any recommendations on how
to stop it? Preferably from the server with code of some sort...

Thanks in advance.

Matt



Hi Matt,

Have you tried to put this two lines in the HEAD section of your HTML pages :
        <META http-equiv="Cache-Control" content="no-cache">
        <META http-equiv="Pragma" content="no-cache">

Hope it helps you.

BR


--- End Message ---
--- Begin Message ---
As Manuel said, have you tried to send no-cache headers and <meta> tags?

--
Nitsan

On Fri, Jun 12, 2009 at 8:04 AM, Manuel C. <[email protected]> wrote:

> Matt Neimeyer a écrit :
>
>  I'm at a complete loss... So I'm hoping someone can point me in the
>> right direction to even start looking.
>>
>> We have an application written in PHP that lets users send out emails.
>> The basic process is as follows.
>>
>> 1. Go to "start" screen. (This resets anything currently in process
>> for the current logged in user)
>> 2. Upload email addresses and other info (Names, etc)
>> 3. Build Email
>> 4. Send
>>
>> In Step 3 the user can click a "Live Preview" button to see what the
>> email will look like with the merged data.
>>
>> Here's the problem,  this works fine in all versions of IE, versions
>> 1.5 or less of FireFox and versions 3 or less of Safari. However,
>> starting in FireFox 2, and now Safari 4, when you get to step four OR
>> click the live preview button in step three there is no more data in
>> the merge. In those browsers the system is acting like the end user
>> went BACK to the start page (in another window?) and reinitialized all
>> the data.
>>
>> I immediately thought it might be pre-fetching so I tried using the
>> system before and after toggling the network.prefetch-next setting in
>> about:config with FireFox 2.0.0.20 and restarting the browser. No
>> luck. So I added code to my reset function to email me the output of
>> phpinfo() when the reset function is called. Using IE I get 1
>> notification. Using FF I get two notifications. This reinforces my
>> theory that FireFox is prefetching the menu item to start a new
>> mailing (just an <a> link...) from the top of the composer page. Even
>> still... I've disabled prefetch so it SHOULDN'T even be considering
>> those links right? I've also tried adding artificial
>> "?now=<timestamp>" fakes to the end of all menu links since I read
>> somewhere (don't remember where) that FireFox only prefetches pages
>> with no query section in the address.
>>
>> Has anyone run into this behavior before? Any recommendations on how
>> to stop it? Preferably from the server with code of some sort...
>>
>> Thanks in advance.
>>
>> Matt
>>
>>
>
> Hi Matt,
>
> Have you tried to put this two lines in the HEAD section of your HTML pages
> :
>        <META http-equiv="Cache-Control" content="no-cache">
>        <META http-equiv="Pragma" content="no-cache">
>
> Hope it helps you.
>
> BR
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---

Reply via email to