php-general Digest 4 Sep 2006 08:42:12 -0000 Issue 4328
Topics (messages 241336 through 241348):
Re: Organizing php functions
241336 by: Ivo F.A.C. Fokkema
Crazy behavior...
241337 by: Peter Lauri
241339 by: Peter Lauri
241341 by: Alex Turner
241342 by: Peter Lauri
241343 by: Alex Turner
241345 by: Peter Lauri
241347 by: Alex Turner
Re: Functions vs html outpuit
241338 by: Dave Goodchild
241340 by: Alex Turner
241344 by: Larry Garfield
Re: local php.ini not recognized in php 5.1.x?
241346 by: Aaron Axelsen
strtotime() strangeness
241348 by: Paul Scott
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 ---
On Fri, 01 Sep 2006 21:35:32 -0600, The Doctor wrote:
> The question comes up because:
>
> Sort file in the path interfere with one another
>
> which leads to
>
> web page malfunction.
>
> Question: should all php programmes such as drupal be placed
> under /usr/local/lib ?
I'm not getting the 'sort file' problem, but you can put PHP apps
wherever; as long as you tell Apache/your webserver where to find it.
--- End Message ---
--- Begin Message ---
Hi,
This is really odd. I use this code to retrive value from a database table.
When the field is empty, it cracks the HTML code some how, the PHP script
seam to not break.
function getInfo() {
$html = "<table>";
$html.=
"<tr><th>Name</th><td>".$this->getName()."</td></tr>";
$html.=
"<tr><th>Description</th><td>".$this->getDesc()."</td></tr>";
$html.=
"<tr><th>Priority</th><td>".$this->getPriorityText()."</td></tr>";
$html.= "</table>";
return $html;
}
The function getDesc is like this (I have made it overly complicated because
I am trying to fix the problem):
function getDesc() {
$Query = sprintf("SELECT todotext FROM teamtodo WHERE id=%d
LIMIT 1", $this->getID());
$Result = mysql_query($Query);
if(mysql_num_rows($Result)>0) {
if($Roww = mysql_fetch_array($Result)) {
if($Roww['todotext']!='') return
$Roww['todotext'];
else return '';
} else return '';
} else return '';
}
When the database field is not empty it works fine, but as soon as the field
todotext is empty the $html seam to break, but the value of $html until the
$this->getDesc() is still being returned by the function (can see half of
the table).
Is this a bug, or am I just stupid? If I just insert some blank spaces it
works, hrm.
/Peter
--- End Message ---
--- Begin Message ---
Just figured out that it seams to happen when the request is done via AJAX.
But it does not make any sense to me that there should be any difference.
/Peter
-----Original Message-----
From: Peter Lauri [mailto:[EMAIL PROTECTED]
Sent: Sunday, September 03, 2006 1:53 PM
To: [email protected]
Subject: [PHP] Crazy behavior...
Hi,
This is really odd. I use this code to retrive value from a database table.
When the field is empty, it cracks the HTML code some how, the PHP script
seam to not break.
function getInfo() {
$html = "<table>";
$html.=
"<tr><th>Name</th><td>".$this->getName()."</td></tr>";
$html.=
"<tr><th>Description</th><td>".$this->getDesc()."</td></tr>";
$html.=
"<tr><th>Priority</th><td>".$this->getPriorityText()."</td></tr>";
$html.= "</table>";
return $html;
}
The function getDesc is like this (I have made it overly complicated because
I am trying to fix the problem):
function getDesc() {
$Query = sprintf("SELECT todotext FROM teamtodo WHERE id=%d
LIMIT 1", $this->getID());
$Result = mysql_query($Query);
if(mysql_num_rows($Result)>0) {
if($Roww = mysql_fetch_array($Result)) {
if($Roww['todotext']!='') return
$Roww['todotext'];
else return '';
} else return '';
} else return '';
}
When the database field is not empty it works fine, but as soon as the field
todotext is empty the $html seam to break, but the value of $html until the
$this->getDesc() is still being returned by the function (can see half of
the table).
Is this a bug, or am I just stupid? If I just insert some blank spaces it
works, hrm.
/Peter
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Peter Lauri wrote:
Just figured out that it seams to happen when the request is done via AJAX.
But it does not make any sense to me that there should be any difference.
/Peter
-----Original Message-----
From: Peter Lauri [mailto:[EMAIL PROTECTED]
Sent: Sunday, September 03, 2006 1:53 PM
To: [email protected]
Subject: [PHP] Crazy behavior...
Hi,
This is really odd. I use this code to retrive value from a database table.
When the field is empty, it cracks the HTML code some how, the PHP script
seam to not break.
function getInfo() {
$html = "<table>";
$html.=
"<tr><th>Name</th><td>".$this->getName()."</td></tr>";
$html.=
"<tr><th>Description</th><td>".$this->getDesc()."</td></tr>";
$html.=
"<tr><th>Priority</th><td>".$this->getPriorityText()."</td></tr>";
$html.= "</table>";
return $html;
}
The function getDesc is like this (I have made it overly complicated because
I am trying to fix the problem):
function getDesc() {
$Query = sprintf("SELECT todotext FROM teamtodo WHERE id=%d
LIMIT 1", $this->getID());
$Result = mysql_query($Query);
if(mysql_num_rows($Result)>0) {
if($Roww = mysql_fetch_array($Result)) {
if($Roww['todotext']!='') return
$Roww['todotext'];
else return '';
} else return '';
} else return '';
}
When the database field is not empty it works fine, but as soon as the field
todotext is empty the $html seam to break, but the value of $html until the
$this->getDesc() is still being returned by the function (can see half of
the table).
Is this a bug, or am I just stupid? If I just insert some blank spaces it
works, hrm.
/Peter
Can you send an example of the broken HTML? What are the symptoms of
the html being broken. Finally, in what way are you using AJAX. This
looks like html output - so is it really AJAH?
My first guess is that something about the context at the browser end
makes <td></td> - an empty table element - cause trouble.
Cheers
AJ
--
www.deployview.com
www.nerds-central.com
www.project-network.com
--- End Message ---
--- Begin Message ---
[snip]
Can you send an example of the broken HTML? What are the symptoms of
the html being broken. Finally, in what way are you using AJAX. This
looks like html output - so is it really AJAH?
My first guess is that something about the context at the browser end
makes <td></td> - an empty table element - cause trouble.
Cheers
AJ
[/snip]
This is really odd. I wrote the $html variable that I send back to the
browser via AJAX, and that code is like this when I pushed it into a
temporary database table:
<table><p style='float: right;'>
<a href='javascript:teamToDoHideInfoBox(1, 6);''>Close</a></p>
<tr><th>Name</th><td>asdf</td></tr>
<tr><th>Description</th><td></td></tr>
<tr><th>Assigned to</th><td></td></tr>
<tr><th>Created by</th><td>Peter Lauri(Farang)</td></tr>
<tr><th>Due date</th><td></td></tr>
<tr><th>Start date</th><td></td></tr>
<tr><th>Priority</th><td>Normal</td></tr>
<tr><th>Creation date</th><td>Sun, 03 Sep 2006 23:09:44 +0700</td></tr>
</table>
However, if I just use that output all is shown until the empty <td></td>
tag.
Then I tried to check what is actually captured by the browser, and it was
showing only until the <td> and then nothing more.
So this should maybe be posted to the JavaScript list :)
I have temporary solved by NOT allowing empty strings into those fields, but
the description should be able to be empty :)
/Peter
--- End Message ---
--- Begin Message ---
Peter,
When it arrives at the browser, via ajax, I am guessing that you then put it
into the page view .innerHTML or some other method.
I suspect your problem revolves around asking the browser to do stuff it should
not really have to do.
There are two issues I would like to highlight with the html.
1) You are mixing TH and TD on the same row. You should be using styles to set
the different presentations of the elements.
2) You have placed a paragraph section between the table tag and the first tr
tag. This is wrong.
I suspect that the browser is managing to cope with this markup when presented
as a static page but is unable to figure out how to update an existing page
with it. If you fix the html to be standards compliant then the chances are
all will be well.
If it is not - by all means get back to me :-)
Best wishes
AJ
Alexander J Turner Ph.D.
www.deployview.com
www.nerds-central.blogspot.com
www.project-network.com
-----Original Message-----
From: Peter Lauri [mailto:[EMAIL PROTECTED]
Sent: 03 September 2006 17:20
To: Alex Turner; [email protected]
Subject: RE: [PHP] Crazy behavior...
[snip]
Can you send an example of the broken HTML? What are the symptoms of
the html being broken. Finally, in what way are you using AJAX. This
looks like html output - so is it really AJAH?
My first guess is that something about the context at the browser end
makes <td></td> - an empty table element - cause trouble.
Cheers
AJ
[/snip]
This is really odd. I wrote the $html variable that I send back to the
browser via AJAX, and that code is like this when I pushed it into a
temporary database table:
<table><p style='float: right;'>
<a href='javascript:teamToDoHideInfoBox(1, 6);''>Close</a></p>
<tr><th>Name</th><td>asdf</td></tr>
<tr><th>Description</th><td></td></tr>
<tr><th>Assigned to</th><td></td></tr>
<tr><th>Created by</th><td>Peter Lauri(Farang)</td></tr>
<tr><th>Due date</th><td></td></tr>
<tr><th>Start date</th><td></td></tr>
<tr><th>Priority</th><td>Normal</td></tr>
<tr><th>Creation date</th><td>Sun, 03 Sep 2006 23:09:44 +0700</td></tr>
</table>
However, if I just use that output all is shown until the empty <td></td>
tag.
Then I tried to check what is actually captured by the browser, and it was
showing only until the <td> and then nothing more.
So this should maybe be posted to the JavaScript list :)
I have temporary solved by NOT allowing empty strings into those fields, but
the description should be able to be empty :)
/Peter
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006
--- End Message ---
--- Begin Message ---
Just thought one thing. I did do a alert() on the http.responseText, and
that breaks in on the <td> too, so the response that is sent back probably
just ends there... weird...
/Peter
-----Original Message-----
From: Alex Turner [mailto:[EMAIL PROTECTED]
Sent: Sunday, September 03, 2006 11:31 PM
To: Peter Lauri
Cc: [email protected]
Subject: RE: [PHP] Crazy behavior...
Peter,
When it arrives at the browser, via ajax, I am guessing that you then put it
into the page view .innerHTML or some other method.
I suspect your problem revolves around asking the browser to do stuff it
should not really have to do.
There are two issues I would like to highlight with the html.
1) You are mixing TH and TD on the same row. You should be using styles to
set the different presentations of the elements.
2) You have placed a paragraph section between the table tag and the first
tr tag. This is wrong.
I suspect that the browser is managing to cope with this markup when
presented as a static page but is unable to figure out how to update an
existing page with it. If you fix the html to be standards compliant then
the chances are all will be well.
If it is not - by all means get back to me :-)
Best wishes
AJ
Alexander J Turner Ph.D.
www.deployview.com
www.nerds-central.blogspot.com
www.project-network.com
-----Original Message-----
From: Peter Lauri [mailto:[EMAIL PROTECTED]
Sent: 03 September 2006 17:20
To: Alex Turner; [email protected]
Subject: RE: [PHP] Crazy behavior...
[snip]
Can you send an example of the broken HTML? What are the symptoms of
the html being broken. Finally, in what way are you using AJAX. This
looks like html output - so is it really AJAH?
My first guess is that something about the context at the browser end
makes <td></td> - an empty table element - cause trouble.
Cheers
AJ
[/snip]
This is really odd. I wrote the $html variable that I send back to the
browser via AJAX, and that code is like this when I pushed it into a
temporary database table:
<table><p style='float: right;'>
<a href='javascript:teamToDoHideInfoBox(1, 6);''>Close</a></p>
<tr><th>Name</th><td>asdf</td></tr>
<tr><th>Description</th><td></td></tr>
<tr><th>Assigned to</th><td></td></tr>
<tr><th>Created by</th><td>Peter Lauri(Farang)</td></tr>
<tr><th>Due date</th><td></td></tr>
<tr><th>Start date</th><td></td></tr>
<tr><th>Priority</th><td>Normal</td></tr>
<tr><th>Creation date</th><td>Sun, 03 Sep 2006 23:09:44 +0700</td></tr>
</table>
However, if I just use that output all is shown until the empty <td></td>
tag.
Then I tried to check what is actually captured by the browser, and it was
showing only until the <td> and then nothing more.
So this should maybe be posted to the JavaScript list :)
I have temporary solved by NOT allowing empty strings into those fields, but
the description should be able to be empty :)
/Peter
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006
--- End Message ---
--- Begin Message ---
Peter,
That is very odd!
When you say 'breaks' do you mean, just stops?
Is it possible that a 0x00 character is getting in there somehow?
It would be good to actually see what is going between the client and the
server. Have you ever used JMeter? If you were to proxy between the two with
JMeter then we would have an 'independent third party' to see what is going on.
Cheers - and good sleeping!
AJ
Alexander J Turner Ph.D.
www.deployview.com
www.nerds-central.blogspot.com
www.project-network.com
-----Original Message-----
From: Peter Lauri [mailto:[EMAIL PROTECTED]
Sent: 03 September 2006 18:02
To: Alex Turner
Cc: [email protected]
Subject: RE: [PHP] Crazy behavior...
Just thought one thing. I did do a alert() on the http.responseText, and
that breaks in on the <td> too, so the response that is sent back probably
just ends there... weird...
/Peter
-----Original Message-----
From: Alex Turner [mailto:[EMAIL PROTECTED]
Sent: Sunday, September 03, 2006 11:31 PM
To: Peter Lauri
Cc: [email protected]
Subject: RE: [PHP] Crazy behavior...
Peter,
When it arrives at the browser, via ajax, I am guessing that you then put it
into the page view .innerHTML or some other method.
I suspect your problem revolves around asking the browser to do stuff it
should not really have to do.
There are two issues I would like to highlight with the html.
1) You are mixing TH and TD on the same row. You should be using styles to
set the different presentations of the elements.
2) You have placed a paragraph section between the table tag and the first
tr tag. This is wrong.
I suspect that the browser is managing to cope with this markup when
presented as a static page but is unable to figure out how to update an
existing page with it. If you fix the html to be standards compliant then
the chances are all will be well.
If it is not - by all means get back to me :-)
Best wishes
AJ
Alexander J Turner Ph.D.
www.deployview.com
www.nerds-central.blogspot.com
www.project-network.com
-----Original Message-----
From: Peter Lauri [mailto:[EMAIL PROTECTED]
Sent: 03 September 2006 17:20
To: Alex Turner; [email protected]
Subject: RE: [PHP] Crazy behavior...
[snip]
Can you send an example of the broken HTML? What are the symptoms of
the html being broken. Finally, in what way are you using AJAX. This
looks like html output - so is it really AJAH?
My first guess is that something about the context at the browser end
makes <td></td> - an empty table element - cause trouble.
Cheers
AJ
[/snip]
This is really odd. I wrote the $html variable that I send back to the
browser via AJAX, and that code is like this when I pushed it into a
temporary database table:
<table><p style='float: right;'>
<a href='javascript:teamToDoHideInfoBox(1, 6);''>Close</a></p>
<tr><th>Name</th><td>asdf</td></tr>
<tr><th>Description</th><td></td></tr>
<tr><th>Assigned to</th><td></td></tr>
<tr><th>Created by</th><td>Peter Lauri(Farang)</td></tr>
<tr><th>Due date</th><td></td></tr>
<tr><th>Start date</th><td></td></tr>
<tr><th>Priority</th><td>Normal</td></tr>
<tr><th>Creation date</th><td>Sun, 03 Sep 2006 23:09:44 +0700</td></tr>
</table>
However, if I just use that output all is shown until the empty <td></td>
tag.
Then I tried to check what is actually captured by the browser, and it was
showing only until the <td> and then nothing more.
So this should maybe be posted to the JavaScript list :)
I have temporary solved by NOT allowing empty strings into those fields, but
the description should be able to be empty :)
/Peter
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 01/09/2006
--- End Message ---
--- Begin Message ---
Thanks, that was what I needed to hear. Cheers.
On 03/09/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote:
On Fri, 01 Sep 2006 16:44:19 +0200, M. Sokolewicz wrote:
> Dave Goodchild wrote:
>> Hi all, this may seem like a silly question, but I am creating a
library of
>> html form element generation function, for example a textarea fucntion
that
>> takes rows and cols as parameters, a function that generates a day,
month
>> and year select box, etc. My question is - is it significantly to
switch
>> off
>> the parser and emit raw html than calling a function? If it is faster
to
>> just allow the server to send the html I will not bother.
>>
>
> I'm not quite sure I understand your question. Are you asking if it's
> faster to parse and process a php script vs. a page of raw HTML?
>
> In that case, OF COURSE SERVING A RAW HTML FILE IS FASTER!!!
> Does the server have to do *anything* with the contents of the HMTL
file? no
> Does the server have to do *anything* with the contents of the PHP file?
> yes! of course! it needs to parse and process it BEFORE it can actually
> server the RESULT of that script.
>
> So, if possible, stick to raw HTML files.
> - tul
That said, if you feel that it saves you a lot of development time (like
me) to use such functions, and you're writing a basic app that will not
likely attract lots of hits, then go for it.
I use a viewForm() function, that takes an array as a argument describing
the required form, for all of my projects. Surely it's faster for the
server if you just write the HTML, but this is much easier for me to
create, edit and re-use in other projects...
Just my 2 cts.
Ivo
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
http://www.web-buddha.co.uk
http://www.projectkarma.co.uk
--- End Message ---
--- Begin Message ---
Dave Goodchild wrote:
Thanks, that was what I needed to hear. Cheers.
On 03/09/06, Ivo F.A.C. Fokkema <[EMAIL PROTECTED]> wrote:
On Fri, 01 Sep 2006 16:44:19 +0200, M. Sokolewicz wrote:
> Dave Goodchild wrote:
>> Hi all, this may seem like a silly question, but I am creating a
library of
>> html form element generation function, for example a textarea fucntion
that
>> takes rows and cols as parameters, a function that generates a day,
month
>> and year select box, etc. My question is - is it significantly to
switch
>> off
>> the parser and emit raw html than calling a function? If it is faster
to
>> just allow the server to send the html I will not bother.
>>
>
> I'm not quite sure I understand your question. Are you asking if it's
> faster to parse and process a php script vs. a page of raw HTML?
>
> In that case, OF COURSE SERVING A RAW HTML FILE IS FASTER!!!
> Does the server have to do *anything* with the contents of the HMTL
file? no
> Does the server have to do *anything* with the contents of the PHP
file?
> yes! of course! it needs to parse and process it BEFORE it can actually
> server the RESULT of that script.
>
> So, if possible, stick to raw HTML files.
> - tul
That said, if you feel that it saves you a lot of development time (like
me) to use such functions, and you're writing a basic app that will not
likely attract lots of hits, then go for it.
I use a viewForm() function, that takes an array as a argument describing
the required form, for all of my projects. Surely it's faster for the
server if you just write the HTML, but this is much easier for me to
create, edit and re-use in other projects...
Just my 2 cts.
Ivo
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
It does seem to me that a lot a pages end up with PHP in them to do
stuff that could be put in raw HTML. The reason being to make the pages
easier to manage and port.
I would go for the optimize late philosophy. Once you have a site
running, load testing it with - eg - JMeter. If a PHP page is taking a
lot of the time and it could easily be converted to static HTML, do it
at that point. If you code raw HTML everywhere, then you might find
that you have spent a day messing with a page that only gets hit once a
day :-(
Best wishes
AJ
--
www.deployview.com
www.nerds-central.com
www.project-network.com
--- End Message ---
--- Begin Message ---
On Sunday 03 September 2006 09:00, Alex Turner wrote:
> I would go for the optimize late philosophy. Once you have a site
> running, load testing it with - eg - JMeter. If a PHP page is taking a
> lot of the time and it could easily be converted to static HTML, do it
> at that point. If you code raw HTML everywhere, then you might find
> that you have spent a day messing with a page that only gets hit once a
> day :-(
>
> Best wishes
>
> AJ
"Pre-mature optimization is the root of all evil."
Unless you're building something you know will be very time sensitive, or a
part of the code that you know will run every single page view, optimize
first for maintainability/modifiability. That is, write code that is easy to
understand and easy to tweak. That means opting for generalized, flexible
code when possible. Sometimes that will mean writing all your HTML via
print, sometimes it will mean static HTML files (although it almost never
does for me), sometimes that will mean including a mostly-HTML file with PHP
print statements into a mostly-PHP function to use as a poor man's template.
In my experience, the time it takes to connect to your SQL database in the
first place will be an order of magnitude larger than whatever it is you're
doing anyway. :-)
--
Larry Garfield AIM: LOLG42
[EMAIL PROTECTED] ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
--- End Message ---
--- Begin Message ---
Marten,
I have also been trying to figure this out. Have you came to any
conclusions? I have done some searching and so far haven't found any
answers. Is there anyone else on the list that can shed some light on this?
Thanks!
-- Aaron
Marten Lehmann wrote:
> Hello,
>
> we switched from php 5.0.6 to 5.1.6. php is running as CGI. We have a global
> php.ini in the /lib directory of the php installation with settings that are
> valid for all users.
>
> In php 5.0.6 (and previous php releases) additionally the local php.ini in the
> directory of the executed php-script has been parsed so users could overwrite
> options like register_globals. But now in php 5.1.6 this local php.ini doesn't
> seem to be recognized at all, not any option in it is evaluated.
>
> Is there anything that changed from php 5.0.x to 5.1.x regarding the handling
> of php.ini's? I don't have any idea what went wrong because I compiled php
> 5.1.6 with the same options as php 5.0.6.
>
> Regards
> Marten
>
>
--
Aaron Axelsen
[EMAIL PROTECTED]
Great hosting, low prices. Modevia Web Services LLC -- http://www.modevia.com
--- End Message ---
--- Begin Message ---
I am trying to convert a date and time (from the apache2 server logs) in
the format of 27/Aug/2006:19:02:20 +0200 to a UNIX timestamp and then
reformat it as a RFC compliant date by using date('r', $thedate);
My problem is as such. In PHP-5.1.2 it works perfectly and returns the
correct date. In PHP-5.1.6 it returns false.
Anyone have a workaround for this? I know that the GNU date format works
with dates like 27 Aug 2006, but what about the time portion?
Any help on this would be massively appreciated!
--Paul
All Email originating from UWC is covered by disclaimer
http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm
--- End Message ---