php-general Digest 21 Mar 2005 10:20:35 -0000 Issue 3350

Topics (messages 211153 through 211173):

Re: php-not-executing-in-html-file-help
        211153 by: Ian Firla
        211154 by: Stephen Johnson
        211157 by: Chris Shiflett

Regex
        211155 by: Colin Ross

Re: see anything wrong (xhtml validator)
        211156 by: Chris Shiflett
        211171 by: Burhan Khalid

Re: is_a() against instanceof
        211158 by: Marek Kilimajer

Re: Help with dates
        211159 by: Kevin

Re: php-not-executing-in-html-file-help-----its working----thanks
        211160 by: vijayaraj nagarajan
        211161 by: Forest Liu

multiple words search query advise
        211162 by: Ryan A

Re: carriage returns using error_log?
        211163 by: Kurt Yoder
        211164 by: Forest Liu
        211165 by: Chris Shiflett

Re: http authentication with safe mode enabled?!
        211166 by: LacaK

php.ini file
        211167 by: Ruel Cima
        211168 by: Kim Madsen
        211172 by: Burhan Khalid
        211173 by: Kim Madsen

Re: [suspicious - maybe spam] [PHP] [suspicious - maybe spam] detecting a 
leading hyphen from post data
        211169 by: Burhan Khalid

Re: fopen
        211170 by: Kim Madsen

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 ---
You need to tell apache to run html files through the php interpreter:

ie. AddType application/x-httpd-php .php .php3 .html

then restart apache

Ian

On Sun, 2005-03-20 at 14:12 -0800, vijayaraj nagarajan wrote:
> hi friends
> i am struggling to solve this problem for the past one
> week...kindly help me..
> 
> my apache runs perfectly...
> this code gives a perfect output in the browser...
> 
> file name: hi.html
> 
> <html><body>
> hihihi
> </body></html>
> 
> but this code doesnot give any output in the
> browser...
> 
> file name: hi.html
> 
> <html><body>
> <?php echo "hihihi"; ?>
> </body></html>
> 
> but, the same file with the php code in it...could be
> executed in the command line, using php... where i am
> getting the expected output...
> 
> i tested to c if my apache doesnt recognise php ...
> 
> this code runs perfectly...in the browser...
> 
> <?php echo "hihihi"; ?>
> 
> if saved as hi.php file...
> the same code saved as .html, is not giving any output
> in the browser...
> 
> kindly help me to figure out this problem...
> 
> thanks
> 
> vijayaraj nagarajan
> graduate student
> the university of southern mississippi
> MS - USA
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
-- 
Ian Firla Consulting
http://ianfirla.com

--- End Message ---
--- Begin Message ---
You need to setup your apache server to accept and parse .html files as PHP.

Add this line or modify it to look like this in your httpd.conf file.

AddType application/x-httpd-php .php .html .shtml

HTH
<?php
/*

Stephen Johnson c | eh
The Lone Coder

http://www.thelonecoder.com
[EMAIL PROTECTED]

562.924.4454 (office)
562.924.4075 (fax) 

continuing the struggle against bad code

*/ 
?>

> From: vijayaraj nagarajan <[EMAIL PROTECTED]>
> Date: Sun, 20 Mar 2005 14:12:38 -0800 (PST)
> To: [email protected]
> Subject: [PHP] php-not-executing-in-html-file-help
> 
> hi friends
> i am struggling to solve this problem for the past one
> week...kindly help me..
> 
> my apache runs perfectly...
> this code gives a perfect output in the browser...
> 
> file name: hi.html
> 
> <html><body>
> hihihi
> </body></html>
> 
> but this code doesnot give any output in the
> browser...
> 
> file name: hi.html
> 
> <html><body>
> <?php echo "hihihi"; ?>
> </body></html>
> 
> but, the same file with the php code in it...could be
> executed in the command line, using php... where i am
> getting the expected output...
> 
> i tested to c if my apache doesnt recognise php ...
> 
> this code runs perfectly...in the browser...
> 
> <?php echo "hihihi"; ?>
> 
> if saved as hi.php file...
> the same code saved as .html, is not giving any output
> in the browser...
> 
> kindly help me to figure out this problem...
> 
> thanks
> 
> vijayaraj nagarajan
> graduate student
> the university of southern mississippi
> MS - USA
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

--- End Message ---
--- Begin Message --- vijayaraj nagarajan wrote:
but this code doesnot give any output in the
browser...

file name: hi.html

<html><body>
<?php echo "hihihi"; ?>
</body></html>

but, the same file with the php code in it...could be
executed in the command line, using php... where i am
getting the expected output...

i tested to c if my apache doesnt recognise php ...

this code runs perfectly...in the browser...

<?php echo "hihihi"; ?>

if saved as hi.php file...
the same code saved as .html, is not giving any output
in the browser...

kindly help me to figure out this problem...

I see no problem. It seems that hi.html is being treates as HTML, and hi.php is being treated as PHP. No surprise there.


You can modify this behavior and make Apache treat .html files as PHP by adding .html to your AddType directive in httpd.conf. Are you really sure this is what you need?

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--- End Message ---
--- Begin Message ---
I'm trying to compress down a php-powered javascript file.
In the file i have php run a bunch of loops and foreaches to build
huge nested arrays for use in the javascript.
Since this will be an often loaded page with ALOT of backend
processing, I've decided to compress the file as much as I can and
cache the resulting 'js' file.
Trimming whitespace, etc have been easy in the buffer i have, but I'm
having trouble trying to remove empty javascript satements that do
nothing but add to the page weight.

code:

/*
remove useless statements like  " case '15': { break;} "
*/
$buffer = 
preg_replace('/case(\s)?\'(\d)\'(\s)?:(\s)?[{](\s)?(break;)?(\s)?[}]/',
'', $buffer);


I have a bad feeling that its something in my regex, but can't quite
tell... I want it to allow for spaces (only), 'break;' should be
optional. and any number.

I usually tend to understand regexs, not sure why this one isn't working out...

Colin

--- End Message ---
--- Begin Message --- Sebastian wrote:
it seems the xhtml validator is throwing an error with:

------------------------------------------------------
Line 530, column 12: value of attribute "id" invalid: "1" cannot start a
name

<div id="179" style="display: none;">
------------------------------------------------------

Do you not trust the description? It seems to me that "1" cannot start a name. I bet $news['id'] starts with a "1" in this case.


I'm not really sure what you're asking...

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--- End Message ---
--- Begin Message --- Sebastian wrote:
it seems the xhtml validator is throwing an error with:

------------------------------------------------------
Line 530, column 12: value of attribute "id" invalid: "1" cannot start a
name

<div id=" 1 79" style="display: none;">
------------------------------------------------------

From :

http://www.w3.org/TR/CSS21/syndata.html#q6

"In CSS 2.1, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [A-Za-z0-9] and ISO 10646 characters U+00A1 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit."

I can't see how this is related to PHP.
--- End Message ---
--- Begin Message --- Jason Barnett wrote:
Christian Stadler wrote:

Eli schrieb:


- ($cls instanceof ClassName)  *requires* from ClassName to be declared,
and generates a fatal error when ClassName is not declared.

How about if (class_exists('ClassName') AND $cls instanceof ClassName) { ... }

Regards,
 Christian Stadler


Nice suggestion!  But I wonder... would it perhaps be better to use the
&& operator instead of the AND operator?  That way in case you are
trying to do an assignment PHP won't bother to check instanceof if the
class_exists() fails.

if (class_exists($class) && $cls instanceof $class)
{

}


The only difference between && and AND is precedence, so the second statement won't be executed with either one.

--- End Message ---
--- Begin Message ---
Dear Jochem and all the others who have offered help,

Thank you all for your assistance! Thanks to all of you I have been able to
reach the next step in the design process!

Thanks ever so much!

Most sincerely,

Kevin
"Jochem Maas" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Kevin wrote:
> > Dear mr. Maas,
>
> no need for 'mr' :-)
>
> >
> > First of all my appologies for taking so long to respond. I had a family
> > death to attend to.
>
> my condolences.
> there is no need to apologise in any case.
>
> ...
>
> >>
> >>why is OBC relevant, I read later on that you take the start of egyptian
> >>civilization as zero. is that not much earlier.
> >
> >
> > Well it's relevant to make a baseline so that I can calculate the
difference
> > from then until now. That's the only reason thusfar.
> >
> >
> >>whats the structure of the egyptian|rpg calendar?
> >
> >
> > A year consists of 769 days, 13 months of 63 days a month, except for
month
> > 13 which has 14 days. Every month has 7 weeks of 9 days, of course month
13
> > is the exception. A day is 24 hours.
> >
>
> a few thoughts:
>
> 1. you have a date in both calendars which represent the same day?
> and/or rather what is day zero in the egyptian calendar in the gregorian
> calendar?
>
> 2. maybe you should store the date internally as number of days since
zero,
> where zero is the first day on the egyptian calendar ......
>
> er, checking this thread again, Richard Lynch puts it better than I can so
> I'll just let you read his answer (again?) and hope it helps!
>
>
> oh one last thing: I notice that in the function you posted you did this:
>
>
>      # Calculating the year in Egypt.
>      $yr_Egypt  = floor($EgyptianDays / 769);
>      # Calculating the Month in Egypt.
>      $mnt_Egypt  = round( ($EgyptianDays-($yr_Egypt*769)) / 63 );
>      # Calculating the Day in Egypt.
>      $dy_Egypt  = round( $EgyptianDays - (($yr_Egypt * 769) + ($mnt_Egypt
* 63)) );
>      # Filling the date array variable with the day, month and year of the
>      Egyptian calendar.
>      $ec_date["Day"]  = $dy_Egypt;
>      $ec_date["Month"] = $mnt_Egypt;
>      $ec_date["Year"] = $yr_Egypt;
>      # Returning the Calculated date.
>      return $ec_date;
>
> which could be written more succinctly as:
>
>
>      /* Calculating the year,month,day in Egypt and returning. */
>      return array (
>      "Year"  => ($y = floor(  $EgyptianDays / 769 )),
>      "Month" => ($m = round( ($EgyptianDays -  ($y * 769)) / 63 )),
>      "Day"   => round(  $EgyptianDays - (($y * 769) + ($m * 63)) ),
>      );
>
> that might inspire you to use less variables in your code, which is a good
thing - but in this
> case completely beside the point. whats less beside the point is that you
use floor() for the year
> and round() for the day and month, I wonder if it helps if you use floor()
for all 3?
>
> beware of floating point rounding errors, compare:
>
> <?php
>
> $EgyptianDays = 10345;
>
> var_dump(
>
> array(
>      "Year"  => ($y = floor(  $EgyptianDays / 769 )),
>      "Month" => ($m = floor( ($EgyptianDays -  ($y * 769)) / 63 )),
>      "Day"   => floor(  $EgyptianDays - (($y * 769) + ($m * 63)) ),
> ),
>
> array(
>      "Year"  => ($y = floor(  $EgyptianDays / 769 )),
>      "Month" => ($m = round( ($EgyptianDays -  ($y * 769)) / 63 )),
>      "Day"   => round(  $EgyptianDays - (($y * 769) + ($m * 63)) ),
> )
>
> );
>
> ?>
>
> kind regards,
> Jochem

--- End Message ---
--- Begin Message ---
hi
ian, chris , stephan and others....

its working..now...
i dont know how come...but its working...
thank you somuch...

vijay



--- Ian Firla <[EMAIL PROTECTED]> wrote:
> 
> You need to tell apache to run html files through
> the php interpreter:
> 
> ie. AddType application/x-httpd-php .php .php3 .html
> 
> then restart apache
> 
> Ian
> 
> On Sun, 2005-03-20 at 14:12 -0800, vijayaraj
> nagarajan wrote:
> > hi friends
> > i am struggling to solve this problem for the past
> one
> > week...kindly help me..
> > 
> > my apache runs perfectly...
> > this code gives a perfect output in the browser...
> > 
> > file name: hi.html
> > 
> > <html><body>
> > hihihi
> > </body></html>
> > 
> > but this code doesnot give any output in the
> > browser...
> > 
> > file name: hi.html
> > 
> > <html><body>
> > <?php echo "hihihi"; ?>
> > </body></html>
> > 
> > but, the same file with the php code in it...could
> be
> > executed in the command line, using php... where i
> am
> > getting the expected output...
> > 
> > i tested to c if my apache doesnt recognise php
> ...
> > 
> > this code runs perfectly...in the browser...
> > 
> > <?php echo "hihihi"; ?>
> > 
> > if saved as hi.php file...
> > the same code saved as .html, is not giving any
> output
> > in the browser...
> > 
> > kindly help me to figure out this problem...
> > 
> > thanks
> > 
> > vijayaraj nagarajan
> > graduate student
> > the university of southern mississippi
> > MS - USA
> > 
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around 
> > http://mail.yahoo.com 
> > 
> -- 
> Ian Firla Consulting
> http://ianfirla.com
> 
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--- End Message ---
--- Begin Message ---
Two ways to resolve it:
1,simplest, rename your file as xxx.php, in order to let php
interpreter to process the script.
2, as just now others saying, add file type 'html' to the list which
interpreter would process.


On Sun, 20 Mar 2005 17:43:52 -0800 (PST), vijayaraj nagarajan
<[EMAIL PROTECTED]> wrote:
> hi
> ian, chris , stephan and others....
> 
> its working..now...
> i dont know how come...but its working...
> thank you somuch...
> 
> vijay
> 
> --- Ian Firla <[EMAIL PROTECTED]> wrote:
> >
> > You need to tell apache to run html files through
> > the php interpreter:
> >
> > ie. AddType application/x-httpd-php .php .php3 .html
> >
> > then restart apache
> >
> > Ian
> >
> > On Sun, 2005-03-20 at 14:12 -0800, vijayaraj
> > nagarajan wrote:
> > > hi friends
> > > i am struggling to solve this problem for the past
> > one
> > > week...kindly help me..
> > >
> > > my apache runs perfectly...
> > > this code gives a perfect output in the browser...
> > >
> > > file name: hi.html
> > >
> > > <html><body>
> > > hihihi
> > > </body></html>
> > >
> > > but this code doesnot give any output in the
> > > browser...
> > >
> > > file name: hi.html
> > >
> > > <html><body>
> > > <?php echo "hihihi"; ?>
> > > </body></html>
> > >
> > > but, the same file with the php code in it...could
> > be
> > > executed in the command line, using php... where i
> > am
> > > getting the expected output...
> > >
> > > i tested to c if my apache doesnt recognise php
> > ...
> > >
> > > this code runs perfectly...in the browser...
> > >
> > > <?php echo "hihihi"; ?>
> > >
> > > if saved as hi.php file...
> > > the same code saved as .html, is not giving any
> > output
> > > in the browser...
> > >
> > > kindly help me to figure out this problem...
> > >
> > > thanks
> > >
> > > vijayaraj nagarajan
> > > graduate student
> > > the university of southern mississippi
> > > MS - USA
> > >
> > >
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Tired of spam?  Yahoo! Mail has the best spam
> > protection around
> > > http://mail.yahoo.com
> > >
> > --
> > Ian Firla Consulting
> > http://ianfirla.com
> >
> >
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
           Sincerely,
                     Forest Liu(åäè)

--- End Message ---
--- Begin Message ---
Hi,
We have an a auction like site, now we have to add a search feature to the
site, the searching will be done for 2 fields:
subject and description (ad_sub, ad_text).

Since i have never done this before, I would appreciate some advise on how
to do it.

I was thinking of getting the search string, running an explode() on it and
then doing a LIKE sql query to get the results on each word...but then that
would add up to quite a bit if even 5 words were written (5 queries each for
the subject and 5 for the text)

Any help in the form of advise, links, code, examples etc would be
appreciated.
After googleing a bit I have gotten a bit of help from some of the pages but
not much, one very helpful bit of advise i got was to ignore works like:
the, a, in
as they are too common...if you have anymore to add, please feel free to
write it.


Thanks in advance,
Ryan



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.7.4 - Release Date: 3/18/2005

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

On Mar 20, 2005, at 4:15 PM, Chris Shiflett wrote:

Kurt Yoder wrote:
Is there any way to tell error_log to keep the newline characters? I am
outputting error messages to the error log so I can look at detailed
status information at the time of the error. However, if I put \n in the
error message, it is treated literally by error_log and I see "\n" in
the log message.

Try using double quotes instead of single quotes.

Hope that helps.

Chris

Heh... no, I was already using double quotes. I also tried using actual carriage returns in the string, that didn't work either.


Is error_log simply incapable of obeying carriage returns within the error string?


--

Kurt Yoder
http://yoderhome.com

--- End Message ---
--- Begin Message ---
I prefer purpose it's the design concept in PHP error log.
If I would design a system containing error msg displaying. I would
also just simplly ignore the carriage returns character which the
programer passes to my system, in order to keep graceful in sight.


On Sun, 20 Mar 2005 21:50:09 -0500, Kurt Yoder <[EMAIL PROTECTED]> wrote:
> 
> On Mar 20, 2005, at 4:15 PM, Chris Shiflett wrote:
> 
> > Kurt Yoder wrote:
> >> Is there any way to tell error_log to keep the newline characters? I
> >> am
> >> outputting error messages to the error log so I can look at detailed
> >> status information at the time of the error. However, if I put \n in
> >> the
> >> error message, it is treated literally by error_log and I see "\n" in
> >> the log message.
> >
> > Try using double quotes instead of single quotes.
> >
> > Hope that helps.
> >
> > Chris
> 
> Heh... no, I was already using double quotes. I also tried using actual
> carriage returns in the string, that didn't work either.
> 
> Is error_log simply incapable of obeying carriage returns within the
> error string?
> 
> --
> 
> Kurt Yoder
> http://yoderhome.com
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


-- 
           Sincerely,
                     Forest Liu(åäè)

--- End Message ---
--- Begin Message --- Kurt Yoder wrote:
Heh... no, I was already using double quotes. I also tried using actual
carriage returns in the string, that didn't work either.

Is error_log simply incapable of obeying carriage returns within the
error string?

No, I've used error_log() plenty, and I've never had a problem. Can you show us a specific example that would let us reproduce the problem locally?


Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

--- End Message ---
--- Begin Message ---
Yes,
documentation says :
"If safe mode is enabled, the uid of the script is added to the realm part
of the WWW-Authenticate header. "

and second :
"The HTTP Authentication hooks in PHP are only available when it is running
as an Apache module and is hence not available in the CGI version"
and also :
"Also note that until PHP 4.3.3, HTTP Authentication did not work using
Microsoft's IIS server with the CGI version of PHP due to a limitation of
IIS ..."

This seems to be a minor bug in PHP concept...
PHP Authentication (Basic) works when :
1. PHP is running as apache module
2. safe_mode=off or safe_mode=on, but external authentication in Apache is
disabled ("PHP uses the presence of an AuthType directive to determine
whether external authentication is in effect")

At this time I do not now, how to help you ? Try report it to bugs ?

--- End Message ---
--- Begin Message ---
hi,

i'm experimenting with php on mandrake 10 and i'm not sure about a few things.
first, where should the php.ini file go? i mean in which folder. next, i need 
to upload files to a database and i dont know what folder to specify as the 
temp folder under the file uploads section in the php.ini nor what 
permissions to give such a folder.

hope someone ca help ASAP!

thanx in advance!

--- End Message ---
--- Begin Message ---
-----Original Message-----
From: Ruel Cima [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 21, 2005 9:12 AM

> i'm experimenting with php on mandrake 10 and i'm not sure about a few 
> things. first, where should the php.ini file go? 

If You compile PHP there�s a parameter to use: 

--with-config-file-path=/usr/local/php.ini

-- 
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen 
Systemudvikler/systemdeveloper

--- End Message ---
--- Begin Message --- Ruel Cima wrote:
hi,

i'm experimenting with php on mandrake 10 and i'm not sure about a few things.
first, where should the php.ini file go?

Check the output of phpinfo(); to see where it is expecting the file to be.

i mean in which folder. next, i need
to upload files to a database and i dont know what folder to specify as the temp folder under the file uploads section in the php.ini nor what permissions to give such a folder.

Use your system wide /tmp folder. I believe this is the default setting in PHP, so it should Just Work (tm)

--- End Message ---
--- Begin Message ---
-----Original Message-----
From: Burhan Khalid [mailto:[EMAIL PROTECTED] 
Sent: Monday, March 21, 2005 8:57 AM

> Check the output of phpinfo(); to see where it is expecting the file
to 
> be.

Works only if the installation is completed and PHP is running ;-)

> Use your system wide /tmp folder.  I believe this is the default
setting 
> in PHP, so it should Just Work (tm)

Hopefully not! Files in /tmp are deleted in most *NIX variants, this is
a _bad_ idea and the name of the folder pretty much tell You so... 

Default path is /usr/local/lib 

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/systemdeveloper

--- End Message ---
--- Begin Message --- Larry Brown wrote:
I know this is pretty petty, but it is a sunday and I'm missing this for
some reason...

I'm trying to detect a leading hyphen in an element of an array.  I've
been using strpos to find strings and if getting 1 as the result, I know
it was at the beginning of the string.  However, "-", "\-", nor "/^-/"
give me a hit?  Could someone throw me a bone here?

if ($string{0} === "-") { echo "Woof"; }

--- End Message ---
--- Begin Message ---
-----Original Message-----
From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] 
Sent: Saturday, March 19, 2005 7:03 AM
To: [email protected]
Subject: [PHP] fopen

> What can I add to get more info from the die? Do I <have> to specify a

> pathname in $defaultfile?

Start by _removing_ @ to get warnings?

$defaultfile = "ffmail.txt"; #default file to write to
@ $results = fopen($datafilename, "a");  #open file and supress errors

You set $defaultfile, but tries to open $datafilename?

-- 
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen 
Systemudvikler/systemdeveloper

--- End Message ---

Reply via email to