php-general Digest 25 Mar 2009 19:38:44 -0000 Issue 6032
Topics (messages 290665 through 290687):
Re: Problems with implode
290665 by: Toke Herkild
290666 by: Toke Herkild
290675 by: Igor Escobar
290682 by: Tom Worster
Re: utf-8-safe replacement for strtr()?
290667 by: Nisse Engström
290683 by: Tom Worster
Namespce operator
290668 by: Richard Heyes
290669 by: Luke
290670 by: Richard Heyes
290672 by: Jochem Maas
290673 by: Christoph Boget
290674 by: Jochem Maas
Writing to dbase (dbf) deletes index (cdx)
290671 by: Rahul S. Johari
Multiple PHP's and php.ini's - Linux 5.2.9/5.2.6
290676 by: kyle.smith
290681 by: kyle.smith
newbe question
290677 by: Andres Gonzalez
290678 by: kyle.smith
290679 by: Andres Gonzalez
290680 by: Andres Gonzalez
Re: A fatal error with php virtual cron
290684 by: ××××× ××§×
290685 by: Igor Escobar
290686 by: ××××× ××§×
290687 by: Igor Escobar
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 ---
Okay, tested in the following manner:
for ($i=12300;$i<12801;$i++){
// List is filled with integers, in the correct charset from PHP
$list[] = $i;
}
$pidList = implode(',', $list);
mail('[email protected], 'debug implode', var_export(array($pidList,
$list),1));
And I got the same error, which indicates that perhaps implode works
just as it should but the representation is off. that in it self would
be okay, but how then do we control that the query is actually correct ?
If we cannot trust the debug output how then can we trust that the query
is doing what it is supposed to do ?
Regards,
Toke
Toke Herkild skrev:
As stated before, packet size not the problem, data is delivered
perfectly from MySQL.
Problem seems to be when the result string is diplayed.
I'll try to do a test with a numeric array:
$list = array(12300..12800); and see what happens.
regards,
Toke
Andrea Giammarchi skrev:
What about MySQL max_allowed_packet setting? is it bigger than
produced string?
To: [email protected]
Date: Tue, 24 Mar 2009 15:23:20 +0100
From: [email protected]
Subject: Re: [PHP] Problems with implode
Per Jessen skrev:
Andrea Giammarchi wrote:
Dunno why you guys started talk about utf-8 problems, he has a list of
ids which should contain only unsigned integers, otherwise I do not
get how that query could work with an implode(',', $whatever)
Very good point - maybe the OP has not yet tested his code that
far? Is
there a possibility that some of the id's are _not_ just plain integers
made up of 0-9?
/Per
And exatly the reason I tried the following:
$list[] = $row['uid'];
$list[] = intval($row['uid']);
$list[] = mb_convert_encoding($row['uid'], 'iso-8859-1');
$list[] = mb_convert_encoding(intval($row['uid']), 'iso-8859-1');
My best bet as for now:
It isn't implode there's the problem, but the length of the string
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_________________________________________________________________
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/
As stated before, packet size not the problem, data is delivered
perfectly from MySQL.
Problem seems to be when the result string is diplayed.
I'll try to do a test with a numeric array:
$list = array(12300..12800); and see what happens.
regards,
Toke
Andrea Giammarchi skrev:
What about MySQL max_allowed_packet setting? is it bigger than
produced string?
To: [email protected]
Date: Tue, 24 Mar 2009 15:23:20 +0100
From: [email protected]
Subject: Re: [PHP] Problems with implode
Per Jessen skrev:
Andrea Giammarchi wrote:
Dunno why you guys started talk about utf-8 problems, he has a list of
ids which should contain only unsigned integers, otherwise I do not
get how that query could work with an implode(',', $whatever)
Very good point - maybe the OP has not yet tested his code that
far? Is
there a possibility that some of the id's are _not_ just plain integers
made up of 0-9?
/Per
And exatly the reason I tried the following:
$list[] = $row['uid'];
$list[] = intval($row['uid']);
$list[] = mb_convert_encoding($row['uid'], 'iso-8859-1');
$list[] = mb_convert_encoding(intval($row['uid']), 'iso-8859-1');
My best bet as for now:
It isn't implode there's the problem, but the length of the string
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_________________________________________________________________
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/
--- End Message ---
--- Begin Message ---
works fine, created a html output to browser which displayed nicely.
- weird
regards
Toke
Toke Herkild skrev:
As stated before, packet size not the problem, data is delivered
perfectly from MySQL.
Problem seems to be when the result string is diplayed.
I'll try to do a test with a numeric array:
$list = array(12300..12800); and see what happens.
regards,
Toke
Andrea Giammarchi skrev:
What about MySQL max_allowed_packet setting? is it bigger than
produced string?
To: [email protected]
Date: Tue, 24 Mar 2009 15:23:20 +0100
From: [email protected]
Subject: Re: [PHP] Problems with implode
Per Jessen skrev:
Andrea Giammarchi wrote:
Dunno why you guys started talk about utf-8 problems, he has a list of
ids which should contain only unsigned integers, otherwise I do not
get how that query could work with an implode(',', $whatever)
Very good point - maybe the OP has not yet tested his code that
far? Is
there a possibility that some of the id's are _not_ just plain integers
made up of 0-9?
/Per
And exatly the reason I tried the following:
$list[] = $row['uid'];
$list[] = intval($row['uid']);
$list[] = mb_convert_encoding($row['uid'], 'iso-8859-1');
$list[] = mb_convert_encoding(intval($row['uid']), 'iso-8859-1');
My best bet as for now:
It isn't implode there's the problem, but the length of the string
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
_________________________________________________________________
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/
--- End Message ---
--- Begin Message ---
Maybe you can reduce your code a little using the range();
<?php
$list = range(12300, 12801);
$pidList = implode(',', $list);
mail('[email protected], 'debug implode', var_export(array($pidList,
$list),1));
?>
it's just a sugestion...
Regards,
Igor Escobar
systems analyst & interface designer
www . igorescobar . com
On Wed, Mar 25, 2009 at 4:42 AM, Toke Herkild <[email protected]> wrote:
> Okay, tested in the following manner:
>
> for ($i=12300;$i<12801;$i++){
> // List is filled with integers, in the correct charset from PHP
> $list[] = $i;
> }
> $pidList = implode(',', $list);
> mail('[email protected], 'debug implode', var_export(array($pidList,
> $list),1));
>
> And I got the same error, which indicates that perhaps implode works just
> as it should but the representation is off. that in it self would be okay,
> but how then do we control that the query is actually correct ?
> If we cannot trust the debug output how then can we trust that the query
> is doing what it is supposed to do ?
>
> Regards,
> Toke
>
> Toke Herkild skrev:
>
> As stated before, packet size not the problem, data is delivered perfectly
>> from MySQL.
>> Problem seems to be when the result string is diplayed.
>> I'll try to do a test with a numeric array:
>> $list = array(12300..12800); and see what happens.
>>
>> regards,
>> Toke
>>
>> Andrea Giammarchi skrev:
>>
>>> What about MySQL max_allowed_packet setting? is it bigger than produced
>>> string?
>>>
>>> To: [email protected]
>>>> Date: Tue, 24 Mar 2009 15:23:20 +0100
>>>> From: [email protected]
>>>> Subject: Re: [PHP] Problems with implode
>>>>
>>>> Per Jessen skrev:
>>>>
>>>>> Andrea Giammarchi wrote:
>>>>>
>>>>> Dunno why you guys started talk about utf-8 problems, he has a list of
>>>>>> ids which should contain only unsigned integers, otherwise I do not
>>>>>> get how that query could work with an implode(',', $whatever)
>>>>>>
>>>>> Very good point - maybe the OP has not yet tested his code that far?
>>>>> Is
>>>>> there a possibility that some of the id's are _not_ just plain integers
>>>>> made up of 0-9?
>>>>>
>>>>> /Per
>>>>>
>>>>> And exatly the reason I tried the following:
>>>> $list[] = $row['uid'];
>>>> $list[] = intval($row['uid']);
>>>> $list[] = mb_convert_encoding($row['uid'], 'iso-8859-1');
>>>> $list[] = mb_convert_encoding(intval($row['uid']), 'iso-8859-1');
>>>>
>>>> My best bet as for now:
>>>> It isn't implode there's the problem, but the length of the string
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>> _________________________________________________________________
>>> More than messages–check out the rest of the Windows Live™.
>>> http://www.microsoft.com/windows/windowslive/
>>>
>>
> As stated before, packet size not the problem, data is delivered perfectly
>> from MySQL.
>> Problem seems to be when the result string is diplayed.
>> I'll try to do a test with a numeric array:
>> $list = array(12300..12800); and see what happens.
>>
>> regards,
>> Toke
>>
>> Andrea Giammarchi skrev:
>>
>>> What about MySQL max_allowed_packet setting? is it bigger than produced
>>> string?
>>>
>>> To: [email protected]
>>>> Date: Tue, 24 Mar 2009 15:23:20 +0100
>>>> From: [email protected]
>>>> Subject: Re: [PHP] Problems with implode
>>>>
>>>> Per Jessen skrev:
>>>>
>>>>> Andrea Giammarchi wrote:
>>>>>
>>>>> Dunno why you guys started talk about utf-8 problems, he has a list of
>>>>>> ids which should contain only unsigned integers, otherwise I do not
>>>>>> get how that query could work with an implode(',', $whatever)
>>>>>>
>>>>> Very good point - maybe the OP has not yet tested his code that far?
>>>>> Is
>>>>> there a possibility that some of the id's are _not_ just plain integers
>>>>> made up of 0-9?
>>>>>
>>>>> /Per
>>>>>
>>>>> And exatly the reason I tried the following:
>>>> $list[] = $row['uid'];
>>>> $list[] = intval($row['uid']);
>>>> $list[] = mb_convert_encoding($row['uid'], 'iso-8859-1');
>>>> $list[] = mb_convert_encoding(intval($row['uid']), 'iso-8859-1');
>>>>
>>>> My best bet as for now:
>>>> It isn't implode there's the problem, but the length of the string
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>> _________________________________________________________________
>>> More than messages–check out the rest of the Windows Live™.
>>> http://www.microsoft.com/windows/windowslive/
>>>
>>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On 3/24/09 9:25 AM, "Andrea Giammarchi" <[email protected]> wrote:
>
> Dunno why you guys started talk about utf-8 problems, he has a list of ids
> which should contain only unsigned integers, otherwise I do not get how that
> query could work with an implode(',', $whatever) rather than 'id in
> ("'.implode('","', array_map('mysql_real_escape_string', $whatever)).'")' ...
> so, the problem could be more about missed ids in the array obtaining ,, ...
> so, in this case, array_filter before, no?
it's certainly possible. but the way toke described his problem did not
imply that his ids were unsigned integers.
SELECT FROM ... WHERE id IN ('aardvark', 'abacus', 'abbey', ..., 'zulu',
'zygote');
--- End Message ---
--- Begin Message ---
On Tue, 24 Mar 2009 08:15:35 -0400, Tom Worster wrote:
> On 3/23/09 2:02 PM, "Tom Worster" <[email protected]> wrote:
>
>> i havea general replacement or workaround for every php function in my code
>> that i know to be utf-8-unsafe. except one: strtr().
>
> strtr() with three parameters is certainly unsafe. but my tests are showing
> that it may be ok with two parameters if the strings in the second parameter
> are well formed utf-8.
>
> does anyone know more? can confirm or contradict?
The two-argument version of strtr() should work fine
since there are no collisions in utf-8 such that part
of one character matches part of a different character.
The question is whether the function is binary safe.
The manual page doesn't say as far as I can tell.
Google came up with the following:
strtr() made binary safe in PHP3:
<http://marc.info/?l=php-general&m=92740681805351&w=4>
Two-argument version added in PHP4:
<http://php.net/ChangeLog-4.php>
/Nisse
--- End Message ---
--- Begin Message ---
thanks for the info.
i'll leave 2-param uses of strtr in my code alone. i have a replacement for
the 3-param version.
btw: i have quite a long checklist of stuff to do when upgrading code for
utf-8, including notes on about 100 functions. do you think it would be
worth putting it on a wiki somewhere?
On 3/25/09 6:32 AM, "Nisse Engström" <[email protected]> wrote:
> On Tue, 24 Mar 2009 08:15:35 -0400, Tom Worster wrote:
>
>> On 3/23/09 2:02 PM, "Tom Worster" <[email protected]> wrote:
>>
>>> i havea general replacement or workaround for every php function in my code
>>> that i know to be utf-8-unsafe. except one: strtr().
>>
>> strtr() with three parameters is certainly unsafe. but my tests are showing
>> that it may be ok with two parameters if the strings in the second parameter
>> are well formed utf-8.
>>
>> does anyone know more? can confirm or contradict?
>
> The two-argument version of strtr() should work fine
> since there are no collisions in utf-8 such that part
> of one character matches part of a different character.
>
> The question is whether the function is binary safe.
> The manual page doesn't say as far as I can tell.
> Google came up with the following:
>
> strtr() made binary safe in PHP3:
> <http://marc.info/?l=php-general&m=92740681805351&w=4>
>
> Two-argument version added in PHP4:
> <http://php.net/ChangeLog-4.php>
>
>
> /Nisse
--- End Message ---
--- Begin Message ---
Backslash? Seriously? I'm hurt that my suggestion of "¬" (ASCII170 ?)
wasn't used. :-(
--
Richard Heyes
HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.net (Updated March 14th)
--- End Message ---
--- Begin Message ---
Backslash doesn't sound like it will look very pretty
2009/3/25 Richard Heyes <[email protected]>
> Backslash? Seriously? I'm hurt that my suggestion of "¬" (ASCII170 ?)
> wasn't used. :-(
>
> --
> Richard Heyes
>
> HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
> http://www.rgraph.net (Updated March 14th)
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Luke Slater
http://dinosaur-os.com/
:O)
--- End Message ---
--- Begin Message ---
> Backslash doesn't sound like it will look very pretty
Well no, but practically I can't see any dis/advantages. Except that
it saves two whole keypresses over something like :::. Think of the
RSI lawsuits prevented...
--
Richard Heyes
HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.net (Updated March 14th)
--- End Message ---
--- Begin Message ---
Luke schreef:
> Backslash doesn't sound like it will look very pretty
>
> 2009/3/25 Richard Heyes <[email protected]>
>
>> Backslash? Seriously? I'm hurt that my suggestion of "¬" (ASCII170 ?)
>> wasn't used. :-(
please kill this thread, the namespace operator was heavily discussed
multiple times in the last 1-2 years on the internals mailing list.
the decision was made a long, long time ago.
if you don't track what's going on with regard to language development
then you have to just lump it ... and if you do track what's going
on and you didn't agree with the arguments and/or decision you also
have to lump it.
>> --
>> Richard Heyes
>>
>> HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
>> http://www.rgraph.net (Updated March 14th)
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
--- End Message ---
--- Begin Message ---
>> Backslash? Seriously? I'm hurt that my suggestion of "¬" (ASCII170 ?)
>> wasn't used. :-(
> Backslash doesn't sound like it will look very pretty
Windows and DOS have been getting away with it for the last 25+ years
so why can't PHP get in on that action? :P
Though I have read the explanation (many, many times) and I still
don't understand why '::' wasn't used. MyClass::MyStaticMethod is
utilizing namespacing. Why it was felt that '::' as the official
namespace operator would mess that up is beyond my ken. :(
thnx,
Christoph
--- End Message ---
--- Begin Message ---
Christoph Boget schreef:
>>> Backslash? Seriously? I'm hurt that my suggestion of "¬" (ASCII170 ?)
>>> wasn't used. :-(
>> Backslash doesn't sound like it will look very pretty
>
> Windows and DOS have been getting away with it for the last 25+ years
> so why can't PHP get in on that action? :P
>
> Though I have read the explanation (many, many times) and I still
> don't understand why '::' wasn't used. MyClass::MyStaticMethod is
> utilizing namespacing.
it's a serious brain hemoraging affair, I had the honour of digging quite
deep into this with Greg Beaver ... he proved beyond a shadow of a doubt that
there we're serious issues ... and trust me he really delved deep into the
problem
(and he's way smarter than *most*)
we're lucky he put in the work.
> Why it was felt that '::' as the official
> namespace operator would mess that up is beyond my ken. :(
>
> thnx,
> Christoph
>
--- End Message ---
--- Begin Message ---
Ave,
I noticed something peculiar and I can't find a solution for this. I'm
wondering if anyone can help me out.
I'm using the dbase functions to read & write from dbf (foxpro)
tables. The DBF tables usually have an Index which is contained in
filename.cdx. It appears that anytime I Write to the dbf table, it
deletes the Index. Is there any way around this?
Here's a simple code that I use for appending to a DBF table:
// open in read-write mode
$db = dbase_open("dbf/myfile.dbf", 2);
// gets the old row
if ($db) {
$record_numbers = dbase_numrecords($db);
for ($i = 1; $i <= $record_numbers; $i++) {
$row = dbase_get_record_with_names($db, $i);
if ($row['SECCODE'] == $_COOKIE['seccodeCookie']) {
unset($row["deleted"]);
// Update fields
$row['f1'] = $_POST['name'];
$row['f2'] = $_POST['email'];
//echo "Replacing Record number $i";
// Replace the record
$row = array_values($row);
dbase_replace_record($db, $row, $i) or die("Fatal
Error");
}
}
}
dbase_close($db);
?>
Thanks.
---
Rahul Sitaram Johari
Founder, Internet Architects Group, Inc.
[Email] [email protected]
[Web] http://www.rahulsjohari.com
--- End Message ---
--- Begin Message ---
I've been wrestling with this issue for a few days, I'm hoping someone
can help.
The issue we had is that we have a system httpd running a custom
php-5.2.9 which is compiled in /opt/php/. The php.ini for this
installation linked to and ioncube accelerator Zend module. The same
apache also hosted some development work, and the developers want to use
Zend Debugger, which cannot be used at the same time as ioncube.
Ioncube is needed for a key application.
So I build a new httpd, and a I built a new php-5.2.9 in
/usr/local/gforge/php-5.2.9, pointing at the new Apache.
After this was all done I noticed (in phpinfo) that it said something
like "configuration file path = /usr/local/gforge/php-5.2.9/lib/,
configuration file loaded = /opt/php/lib/php.ini". I shrugged it off,
added a PHPIni apache directive and called it a night.
Come to find out that this application (GForge) uses some php-based
scripts linked in with their CVS. I don't know that gritty details.
Anyway, it uses the system php, which of course links to php.ini in
/opt/php/lib.php. I figured it would be a simple task to symlink the
system php to this new build of php and it would reference the correct
php.ini. Here's where the confusion sets in.
[r...@dev2 php-5.2.9]# /usr/local/gforge/php-5.2.9/bin/php -i|grep
php.ini
Configuration File (php.ini) Path => /usr/local/gforge/php-5.2.9/lib/
Loaded Configuration File => /opt/php/lib/php.ini
The path explicitly says "/usr/local/...", yet it loads the
"/opt/php/lib/php.ini" file. However, if I set:
[r...@dev2 php-5.2.9]# /usr/local/gforge/php-5.2.9/bin/php -c
/usr/local/gforge/php-5.2.9/lib/ -i|grep php.ini
Configuration File (php.ini) Path => /usr/local/gforge/php-5.2.9/lib/
Loaded Configuration File => /usr/local/gforge/php-5.2.9/lib/php.ini
Bingo! Great news. Sort of... I don't want to have to modify every
CVS script to add a -c <path> option to the php request. Why should I
have to? That should be the first place it looks, right?
I recompiled php with
--with-config-file-path=/usr/local/gforge/php-5.2.9/lib/. Same results.
I compiled php 5.2.6 with the same options. Same results.
Am I missing something?
Any help is greatly appreciated!
Thank you,
Kyle Smith
--- End Message ---
--- Begin Message ---
After further suffering, I've discovered this was due to the source tree
being used to build two PHPs. I'm not sure the exact cause, but I
removed the entire php-5.2.9/ tree and re-extracted the tarball. My new
PHP correctly points at /usr/local/.
Maybe this will help someone else in the same position.
- Kyle
-----Original Message-----
From: kyle.smith [mailto:[email protected]]
Sent: Wednesday, March 25, 2009 10:56 AM
To: [email protected]
Subject: [PHP] Multiple PHP's and php.ini's - Linux 5.2.9/5.2.6
I've been wrestling with this issue for a few days, I'm hoping someone
can help.
The issue we had is that we have a system httpd running a custom
php-5.2.9 which is compiled in /opt/php/. The php.ini for this
installation linked to and ioncube accelerator Zend module. The same
apache also hosted some development work, and the developers want to use
Zend Debugger, which cannot be used at the same time as ioncube.
Ioncube is needed for a key application.
So I build a new httpd, and a I built a new php-5.2.9 in
/usr/local/gforge/php-5.2.9, pointing at the new Apache.
After this was all done I noticed (in phpinfo) that it said something
like "configuration file path = /usr/local/gforge/php-5.2.9/lib/,
configuration file loaded = /opt/php/lib/php.ini". I shrugged it off,
added a PHPIni apache directive and called it a night.
Come to find out that this application (GForge) uses some php-based
scripts linked in with their CVS. I don't know that gritty details.
Anyway, it uses the system php, which of course links to php.ini in
/opt/php/lib.php. I figured it would be a simple task to symlink the
system php to this new build of php and it would reference the correct
php.ini. Here's where the confusion sets in.
[r...@dev2 php-5.2.9]# /usr/local/gforge/php-5.2.9/bin/php -i|grep
php.ini Configuration File (php.ini) Path =>
/usr/local/gforge/php-5.2.9/lib/ Loaded Configuration File =>
/opt/php/lib/php.ini
The path explicitly says "/usr/local/...", yet it loads the
"/opt/php/lib/php.ini" file. However, if I set:
[r...@dev2 php-5.2.9]# /usr/local/gforge/php-5.2.9/bin/php -c
/usr/local/gforge/php-5.2.9/lib/ -i|grep php.ini Configuration File
(php.ini) Path => /usr/local/gforge/php-5.2.9/lib/ Loaded Configuration
File => /usr/local/gforge/php-5.2.9/lib/php.ini
Bingo! Great news. Sort of... I don't want to have to modify every
CVS script to add a -c <path> option to the php request. Why should I
have to? That should be the first place it looks, right?
I recompiled php with
--with-config-file-path=/usr/local/gforge/php-5.2.9/lib/. Same results.
I compiled php 5.2.6 with the same options. Same results.
Am I missing something?
Any help is greatly appreciated!
Thank you,
Kyle Smith
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi,
I want to learn PHP so I started using it for all of my general purpose
scripts. The general format of my scripts are like this:
#!/usr/bin/php
<?php
.....bla bla bla PHP code
?>
When I run my scripts and I have an echo (or print) at the end of the
script to print out the results of the script, I get an extra line feed
printed out. It seems that I can use this:
echo " bla bla bla with no terminating line feed";
and I will not get a line feed. But when I use the echo at the end of
the script I get a terminating line feed. Is this correct or am I
misinterpreting this?
Does echo and print always terminate the string with a \n ?
The function manual does not seem to mention anything about this.
thanks,
-Andres
--- End Message ---
--- Begin Message ---
I'm not sure it will resolve your issue, but the closing ?> is not a
requirement and will eliminate any chance of you adding whitespace to
the end of your scripts:
#!/usr/bin/php
<?php
echo "I'm some script output!"
is a valid script.
---
Kyle Smith
Unix Systems Administrator
Inforonics, LLC
-----Original Message-----
From: Andres Gonzalez [mailto:[email protected]]
Sent: Wednesday, March 25, 2009 11:29 AM
To: [email protected]
Subject: [PHP] newbe question
Hi,
I want to learn PHP so I started using it for all of my general purpose
scripts. The general format of my scripts are like this:
#!/usr/bin/php
<?php
.....bla bla bla PHP code
?>
When I run my scripts and I have an echo (or print) at the end of the
script to print out the results of the script, I get an extra line feed
printed out. It seems that I can use this:
echo " bla bla bla with no terminating line feed";
and I will not get a line feed. But when I use the echo at the end of
the script I get a terminating line feed. Is this correct or am I
misinterpreting this?
Does echo and print always terminate the string with a \n ?
The function manual does not seem to mention anything about this.
thanks,
-Andres
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I just figured this out.
It all depends on what is AFTER the last ?> tag.
If I do not have extra line feeds they are not printed.
Wow...
thanks,
-Andres
Andres Gonzalez wrote:
Hi,
I want to learn PHP so I started using it for all of my general
purpose scripts. The general format of my scripts are like this:
#!/usr/bin/php
<?php
.....bla bla bla PHP code
?>
When I run my scripts and I have an echo (or print) at the end of the
script to print out the results of the script, I get an extra line
feed printed out. It seems that I can use this:
echo " bla bla bla with no terminating line feed";
and I will not get a line feed. But when I use the echo at the end of
the script I get a terminating line feed. Is this correct or am I
misinterpreting this?
Does echo and print always terminate the string with a \n ?
The function manual does not seem to mention anything about this.
thanks,
-Andres
--- End Message ---
--- Begin Message ---
thanks for your response kyle, I did not realize that.
-Andres
kyle.smith wrote:
I'm not sure it will resolve your issue, but the closing ?> is not a
requirement and will eliminate any chance of you adding whitespace to
the end of your scripts:
#!/usr/bin/php
<?php
echo "I'm some script output!"
is a valid script.
---
Kyle Smith
Unix Systems Administrator
Inforonics, LLC
-----Original Message-----
From: Andres Gonzalez [mailto:[email protected]]
Sent: Wednesday, March 25, 2009 11:29 AM
To: [email protected]
Subject: [PHP] newbe question
Hi,
I want to learn PHP so I started using it for all of my general purpose
scripts. The general format of my scripts are like this:
#!/usr/bin/php
<?php
.....bla bla bla PHP code
?>
When I run my scripts and I have an echo (or print) at the end of the
script to print out the results of the script, I get an extra line feed
printed out. It seems that I can use this:
echo " bla bla bla with no terminating line feed";
and I will not get a line feed. But when I use the echo at the end of
the script I get a terminating line feed. Is this correct or am I
misinterpreting this?
Does echo and print always terminate the string with a \n ?
The function manual does not seem to mention anything about this.
thanks,
-Andres
--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hello,
There is some week than I trying to solve a critical error on my VirtualCron
script.
*First of all what is VirtualCron?:*
Virtual cron is script that`s call(http request) himself and doing the
"jobs" by the time(like a cron-jobs on linux, but this script build on php
and its make it independent by the Operation System and the access to the
server. [wordpress build something like that too]).
*How my system works?:*
I have a page(cron.php) and I set this settings:
ignore_user_abort(true);
set_time_limit(0);
sleep(1); //setting the base time unit
I call to the script by socket connection with timout of 0.5s and with
non-blocking mode.
Additionaly I have a log system that save a file with the error when they
happend. andI can "kill" the script by deleting "pid" file.
*Well what`s happend?:*
The script works well when I tune a job to work more 5min from the running
time.
But from some reason the script stop to run after some seconds.. and the
system`s log dosent show any php`s error.
BUT I found this error on my apache`s logs:
*[Wed Mar 25 10:25:19 2009] [error] [client 67.205.44.109] Premature end of
script headers: cron.php*
I hope thats someone know what I have to do..
Thanks a lot,
Almog Baku, Israel.
*
*** My script run on Shared DreamHost, with php5 & apache on linux ***
*
________________
*
צור איתי קשר:* <http://www.facebook.com/profile.php?id=682327963>
--- End Message ---
--- Begin Message ---
Maybe your problem are in the way you're calling your program by socket.
If you show me this part of the code, maybe i can help you.
Regards,
Igor Escobar
systems analyst & interface designer
www . igorescobar . com
On Wed, Mar 25, 2009 at 4:01 PM, אלמוג בקו <[email protected]> wrote:
> Hello,
> There is some week than I trying to solve a critical error on my
> VirtualCron
> script.
>
> *First of all what is VirtualCron?:*
> Virtual cron is script that`s call(http request) himself and doing the
> "jobs" by the time(like a cron-jobs on linux, but this script build on php
> and its make it independent by the Operation System and the access to the
> server. [wordpress build something like that too]).
>
> *How my system works?:*
> I have a page(cron.php) and I set this settings:
>
> ignore_user_abort(true);
> set_time_limit(0);
> sleep(1); //setting the base time unit
>
> I call to the script by socket connection with timout of 0.5s and with
> non-blocking mode.
>
> Additionaly I have a log system that save a file with the error when they
> happend. andI can "kill" the script by deleting "pid" file.
>
> *Well what`s happend?:*
> The script works well when I tune a job to work more 5min from the running
> time.
> But from some reason the script stop to run after some seconds.. and the
> system`s log dosent show any php`s error.
>
> BUT I found this error on my apache`s logs:
> *[Wed Mar 25 10:25:19 2009] [error] [client 67.205.44.109] Premature end of
> script headers: cron.php*
>
>
> I hope thats someone know what I have to do..
> Thanks a lot,
> Almog Baku, Israel.
>
> *
> *** My script run on Shared DreamHost, with php5 & apache on linux ***
> *
> ________________
>
>
> *
> צור איתי קשר:* <http://www.facebook.com/profile.php?id=682327963
> >
>
--- End Message ---
--- Begin Message ---
This is a part of the class:
private function _request() {
//URL information
$url = "http://".$_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$url_info = parse_url($url);
//Fixing port
if(!isset($url_info['port'])) $url_info['port']=80;
//Send "Cron-data"
$data = array(
'jobs' => base64_encode(var_export($this->jobs, true)),
'firstRun' => base64_encode($this->firstRun)
);
$data=http_build_query($data);
//Headers
$headers = ""
."POST " . $url . " HTTP/1.0 \r\n"
."HOST: " . $url_info['host'] . ":" . $url_info['port'] . "
\r\n"
."Content-type: application/x-www-form-urlencoded \r\n"
."Content-Length: " . strlen($data) . " \r\n"
."User-Agent: phpCron \r\n"
."Connection: close\r\n\r\n"
.$data
;
//Error vars
$errstr = null;
$errno = null;
$fp = fsockopen($_SERVER['HTTP_HOST'], $_SERVER['SERVER_PORT'], $errno,
$errstr, 0.5);
if($fp) {
@fwrite($fp, $headers);
@stream_set_timeout($fp, 0.5);
@stream_set_blocking($fp, 0);
@fclose($fp);
return true;
} else {
$this->error = array('socket'=>array('errstr'=>$errstr,
'errno'=>$errno));
return false;
}
}
________________
*
צור איתי קשר:* <http://www.facebook.com/profile.php?id=682327963>
On Wed, Mar 25, 2009 at 9:17 PM, Igor Escobar <[email protected]> wrote:
> Maybe your problem are in the way you're calling your program by socket.
>
> If you show me this part of the code, maybe i can help you.
>
> Regards,
>
> Igor Escobar
> systems analyst & interface designer
> www . igorescobar . com
>
>
>
> On Wed, Mar 25, 2009 at 4:01 PM, אלמוג בקו <[email protected]> wrote:
>
>> Hello,
>> There is some week than I trying to solve a critical error on my
>> VirtualCron
>> script.
>>
>> *First of all what is VirtualCron?:*
>> Virtual cron is script that`s call(http request) himself and doing the
>> "jobs" by the time(like a cron-jobs on linux, but this script build on php
>> and its make it independent by the Operation System and the access to the
>> server. [wordpress build something like that too]).
>>
>> *How my system works?:*
>> I have a page(cron.php) and I set this settings:
>>
>> ignore_user_abort(true);
>> set_time_limit(0);
>> sleep(1); //setting the base time unit
>>
>> I call to the script by socket connection with timout of 0.5s and with
>> non-blocking mode.
>>
>> Additionaly I have a log system that save a file with the error when they
>> happend. andI can "kill" the script by deleting "pid" file.
>>
>> *Well what`s happend?:*
>> The script works well when I tune a job to work more 5min from the running
>> time.
>> But from some reason the script stop to run after some seconds.. and the
>> system`s log dosent show any php`s error.
>>
>> BUT I found this error on my apache`s logs:
>> *[Wed Mar 25 10:25:19 2009] [error] [client 67.205.44.109] Premature end
>> of
>> script headers: cron.php*
>>
>>
>> I hope thats someone know what I have to do..
>> Thanks a lot,
>> Almog Baku, Israel.
>>
>> *
>> *** My script run on Shared DreamHost, with php5 & apache on linux ***
>> *
>> ________________
>>
>>
>> *
>> צור איתי קשר:* <
>> http://www.facebook.com/profile.php?id=682327963>
>>
>
>
--- End Message ---
--- Begin Message ---
Try the ignore_user_abort(true);
Regards,
Igor Escobar
systems analyst & interface designer
www . igorescobar . com
On Wed, Mar 25, 2009 at 4:21 PM, אלמוג בקו <[email protected]> wrote:
> This is a part of the class:
>
> private function _request() {
> //URL information
> $url = "http://".$_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
> $url_info = parse_url($url);
>
> //Fixing port
> if(!isset($url_info['port'])) $url_info['port']=80;
>
>
> //Send "Cron-data"
> $data = array(
> 'jobs' => base64_encode(var_export($this->jobs, true)),
> 'firstRun' => base64_encode($this->firstRun)
> );
> $data=http_build_query($data);
>
> //Headers
> $headers = ""
> ."POST " . $url . " HTTP/1.0 \r\n"
> ."HOST: " . $url_info['host'] . ":" . $url_info['port'] . "
> \r\n"
> ."Content-type: application/x-www-form-urlencoded \r\n"
> ."Content-Length: " . strlen($data) . " \r\n"
> ."User-Agent: phpCron \r\n"
> ."Connection: close\r\n\r\n"
> .$data
> ;
>
> //Error vars
> $errstr = null;
> $errno = null;
>
> $fp = fsockopen($_SERVER['HTTP_HOST'], $_SERVER['SERVER_PORT'], $errno,
> $errstr, 0.5);
> if($fp) {
> @fwrite($fp, $headers);
> @stream_set_timeout($fp, 0.5);
> @stream_set_blocking($fp, 0);
> @fclose($fp);
> return true;
> } else {
> $this->error = array('socket'=>array('errstr'=>$errstr,
> 'errno'=>$errno));
> return false;
> }
> }
>
> ________________
>
>
> *
> צור איתי קשר:*
> <http://www.facebook.com/profile.php?id=682327963>
>
>
> On Wed, Mar 25, 2009 at 9:17 PM, Igor Escobar <[email protected]>wrote:
>
>> Maybe your problem are in the way you're calling your program by socket.
>>
>> If you show me this part of the code, maybe i can help you.
>>
>> Regards,
>>
>> Igor Escobar
>> systems analyst & interface designer
>> www . igorescobar . com
>>
>>
>>
>> On Wed, Mar 25, 2009 at 4:01 PM, אלמוג בקו <[email protected]> wrote:
>>
>>> Hello,
>>> There is some week than I trying to solve a critical error on my
>>> VirtualCron
>>> script.
>>>
>>> *First of all what is VirtualCron?:*
>>> Virtual cron is script that`s call(http request) himself and doing the
>>> "jobs" by the time(like a cron-jobs on linux, but this script build on
>>> php
>>> and its make it independent by the Operation System and the access to the
>>> server. [wordpress build something like that too]).
>>>
>>> *How my system works?:*
>>> I have a page(cron.php) and I set this settings:
>>>
>>> ignore_user_abort(true);
>>> set_time_limit(0);
>>> sleep(1); //setting the base time unit
>>>
>>> I call to the script by socket connection with timout of 0.5s and with
>>> non-blocking mode.
>>>
>>> Additionaly I have a log system that save a file with the error when they
>>> happend. andI can "kill" the script by deleting "pid" file.
>>>
>>> *Well what`s happend?:*
>>> The script works well when I tune a job to work more 5min from the
>>> running
>>> time.
>>> But from some reason the script stop to run after some seconds.. and the
>>> system`s log dosent show any php`s error.
>>>
>>> BUT I found this error on my apache`s logs:
>>> *[Wed Mar 25 10:25:19 2009] [error] [client 67.205.44.109] Premature end
>>> of
>>> script headers: cron.php*
>>>
>>>
>>> I hope thats someone know what I have to do..
>>> Thanks a lot,
>>> Almog Baku, Israel.
>>>
>>> *
>>> *** My script run on Shared DreamHost, with php5 & apache on linux ***
>>> *
>>> ________________
>>>
>>>
>>> *
>>> צור איתי קשר:* <
>>> http://www.facebook.com/profile.php?id=682327963>
>>>
>>
>>
>
--- End Message ---