php-general Digest 11 Jan 2005 12:09:22 -0000 Issue 3221
Topics (messages 206038 through 206068):
Re: Unique, "hard" session timeout on a shared server
206038 by: Richard Lynch
Re: Comparison Operator
206039 by: Richard Lynch
Re: 403 not working -- apache 2 / php5 / linux
206040 by: Richard Lynch
206043 by: Rasmus Lerdorf
206045 by: Jason Morehouse
206048 by: Rasmus Lerdorf
Re: if(date("Y-m-d") >
206041 by: Richard Lynch
Re: sorting mysql results
206042 by: Andrew Kreps
206046 by: Leif Gregory
206047 by: Leon Poon
Security - chmod 777 - PHP upload/write
206044 by: SED
206051 by: Curt Zirzow
test
206049 by: shimuqiheb.abchina.com
Re: What program to use to make thumbnail images?
206050 by: John Holmes
206052 by: Curt Zirzow
Re: unable to load curl
206053 by: Sagar C Nannapaneni
Forms on PHP
206054 by: PHPDiscuss - PHP Newsgroups and mailing lists
Error loading extension dlls in WindosXP for PHP4.3.10
206055 by: Ranjan K. Baisak
206056 by: Ranjan K. Baisak
206060 by: Lester Caine
206063 by: Ranjan K. Baisak
206064 by: Lester Caine
206066 by: Ranjan K. Baisak
206068 by: Lester Caine
Functions in replacement string of eregi_replace
206057 by: Ville Mattila
206065 by: M. Sokolewicz
SOLVED: Global class instances mysteriously set to NULL
206058 by: James \(IFMS\)
$_GET & $_POST simultaneously
206059 by: Bostjan Skufca . domenca.com
206061 by: Lars B. Jensen
206062 by: Bostjan Skufca . domenca.com
2 dimensional array processing
206067 by: Benjamin Edwards
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 ---
[EMAIL PROTECTED] wrote:
> I have researched a few ways to set a "hard" session timeout on a shared
> server. Does anyone have comments on the advantages/disadvantages of each
> approach? Are there other alternatives?
>
> 1. Override the php.ini settings in an .htaccess file:
>
> php_value session.gc_maxlifetime 900
> php_value session.gc_divisor 1
> php_value session.gc_probability 1
>
> 2. Put a "previous request" timestamp into the session, and compare it to
> the current timestamp on a request.
The advantage is that you can then put your time-out into the database as
a config option, and play with it as you see fit in an admin section
slightly easier then editing .htaccess, or MUCH easier for, say, a client.
Gives you a bit more flexibility and control over your sessions.
> 3. Set a <meta> refresh to a "kill session" script.
Not real reliable, but can be useful for those browsers that do it.
> Will there be a performance hit for all applications on the server under
> the first method?
No.
Well, sorta.
Two Facts:
1. If you turn on .htaccess in httpd.conf, it slows Apache down, since it
needs to hit the hard drive to find if you have .htaccess in every
directory up to the DocumentRoot
2. What you set in .htaccess applies to all directories *BELOW* (and
including) the .htaccess file. So it would affect the applications
installed in descendent-directories of the directory containing the
.htaccess
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Chadwick, Russell wrote:
>
> The function this is from sometimes uses $_POST or $_GET input, so
> sometimes its comparing 1337 with '1337' and === would break that.
>
> so I'll have to use something like:
>
> if (($value == $curval) && !(is_string ($curval) && ($value == 0)))
>
> unless there is a better way
Hard to say, without knowing what the function is, what it's supposed to
do, who's calling it and why/when/where...
I'll take a wild stab at it, though, and suggest that if you care about
data types that much, then you should be converting your $_GET/$_POST to
(int) in the first place.
Plus, you should be converting your $_GET/$_POST data to (int) when
appropriate for your data scrubbing (security).
So, really, you should have:
<?php
$curval = (int) (isset($_GET['curval']) ? $_GET['curval'] : 0);
...
your_function(1337, $curval);
...
?>
Then you can use === in your function safely.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
> On Jan 10, 2005, at 12:49 PM, Jason Morehouse wrote:
>
>> Hello. I'm not sure if this is an apache problem or php... but
>> wondering if anyone has come across the same problem.
>>
>> -rw------- 1 root root test.html
>> -rw------- 1 root root test.php
>>
>> Trying to access test.html via a browser servers up the apache 403
>> error page. The test.php however produces:
>>
>> Warning: Unknown: failed to open stream: Permission denied in Unknown
>> on line 0 Warning: Unknown: Failed opening '/www/test.php' for
>> inclusion (include_path='.:/www/php') in Unknown on line 0
Ahhhh! Now we see the question! Why doesn't it yield 403 like it "should"
First and foremost, use php.ini or httpd.conf or .htaccess to *NOT* let
PHP send error messages OF ANY KIND to the browser on a production site.
[You could also use ini_set within a script if the file in question is to
be include'd into other files.]
You should do this anyway.
Admittedly, your server still behaves not quite like you want, as *.html
yields a 403 response, and *.php yields a 200 response, and a page of no
content. But at least the Bad Guys don't see your server internals.
I don't think there's any way you can configure Apache to pre-empt the PHP
trying to read the file -- though I presume Apache *could* be altered to
behave that way... Except it would be rather difficult for Apache to
'know' a priori what User PHP runs as, given suexec, CGI setups, etc...
Depending on your application, you might be able to "wrap" all the access
to files through a known good PHP file, and then use PHP error handling
(http://php.net/set_error_handler) to determine if this error occurred,
and then send a 403 header.
Probably an Apache list would be better suited to knowing for sure any way
around this... You could maybe tweak the PHP source to detect this
condition and send 403 instead of trying to include() the file, which is
what it seems to be doing.
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
Jason Barnett wrote:
the wrong permissions. Why does apache not server the 403 on the php
page? Maybe this is better off in the apache list.
Yeah, this is really better on an Apache list... but...
http://httpd.apache.org/docs/mod/core.html#errordocument
No, it has nothing to do with Apache. Apache doesn't open the file, PHP
does. You could argue that PHP should try to throw a 403 on a
permissions error, but the problem is that it is really too late in the
game to do so once we get to the content handler phase where PHP lives.
It could be hacked to do it a number of ways, but it wouldn't be pretty
and it wouldn't be very consistent either since we would have to only do
it if no output has been sent on the request yet. So a sub-request or
an auto-prepend would both change the behaviour.
Turning off display_errors really is the answer to the particular
security concern raised here.
-Rasmus
--- End Message ---
--- Begin Message ---
Richard Lynch wrote:
Ahhhh! Now we see the question! Why doesn't it yield 403 like it "should"
First and foremost, use php.ini or httpd.conf or .htaccess to *NOT* let
PHP send error messages OF ANY KIND to the browser on a production site.
[You could also use ini_set within a script if the file in question is to
be include'd into other files.]
You should do this anyway.
Admittedly, your server still behaves not quite like you want, as *.html
yields a 403 response, and *.php yields a 200 response, and a page of no
content. But at least the Bad Guys don't see your server internals.
I don't think there's any way you can configure Apache to pre-empt the PHP
trying to read the file -- though I presume Apache *could* be altered to
behave that way... Except it would be rather difficult for Apache to
'know' a priori what User PHP runs as, given suexec, CGI setups, etc...
Depending on your application, you might be able to "wrap" all the access
to files through a known good PHP file, and then use PHP error handling
(http://php.net/set_error_handler) to determine if this error occurred,
and then send a 403 header.
Probably an Apache list would be better suited to knowing for sure any way
around this... You could maybe tweak the PHP source to detect this
condition and send 403 instead of trying to include() the file, which is
what it seems to be doing.
Yeah, thanks all. I usually have error logging off, but enabled it from
time to time when hunting down bugs (and forget to add it back).
Anyway, I guess I'll have to deal with just blank pages coming up in the
event of a .php 403... not a big deal really, I just prefer constancy.
I still don't really get why apache hands parsing off to php when it
knows it doesn't have read access to the file, but I'll save that for
another list!
Thanks again.
-J
--
Jason Morehouse
Vendorama - Create your own online store
http://www.vendorama.com
--- End Message ---
--- Begin Message ---
Jason Morehouse wrote:
I still don't really get why apache hands parsing off to php when it
knows it doesn't have read access to the file, but I'll save that for
another list!
It could check, I suppose, but it doesn't always know that just because
it can't access the file the receiver won't be able to. For example,
mod_suexec can run something to handle the request as a different user
id, so Apache wouldn't have any clue whether or not the destination
handler is able to read the file or not.
Other times Apache hands something off to PHP which may not be treated
as a file at all by PHP. For example, you might have an auto_prepend
script that looks at the filename itself and uses that to do something
without actually trying to access the file.
A quick little Apache module that runs in the filename translation hook
or perhaps the auth hook would solve this particular problem for you.
Shouldn't be more than a 5-liner but it isn't something Apache can do by
default without potentially breaking many things out there.
-Rasmus
--- End Message ---
--- Begin Message ---
> On Mon, 10 Jan 2005 13:08:28 -0500, John Taylor-Johnston
> <[EMAIL PROTECTED]> wrote:
>> Hi,
>> I would like some help to improve this script. I'm a teacher with a
>> schedule of 17 weeks.
>> Instead of using if(date("Y-m-d") >= $week3) I would like to do a "for
>> i = 1 to 17" and if the current date date("Y-m-d") = week[i] I would
>> like to echo "This is week $week[i]";
>>
>> Can someone show me how please?
You could also consider using http://php.net/date with the 'W' (ISO-8601
week number of year, weeks starting on Monday (added in PHP 4.1.0))
argument or 'z' (The day of the year (starting from 0)) and divide by 7.
You'd need to compute your offset to your 'first' week that you care
about, but...
<?php
//PHP 4.1.0 and up:
$start_week = date('W', mktime(0, 0, 0, 9, 4, 2005));
echo "This is week: ", date('W', mktime(0, 0, 0, 10, 1, 2005)) -
$start_week, "<BR>\n";
?>
Depending on what you are doing and how you are already storing dates,
this could be cleaner.
Watch out, though, as you'll have issues on New Year's Eve if that's in
the middle of a 17-week period, as I suspect it is...
You could also just use:
<?php
$start_week = mktime(0, 0, 0, 8, 2, 2005);
function seconds_to_week($seconds){
return $seconds / (60*60*24*7);
}
echo "This is week: ", seconds_to_week(mktime(0, 0, 0, 9, 17, 2005)),
"<BR>\n";
?>
--
Like Music?
http://l-i-e.com/artists.htm
--- End Message ---
--- Begin Message ---
On Mon, 10 Jan 2005 16:38:18 -0500, Sebastian
<[EMAIL PROTECTED]> wrote:
> I have a list of rows in the database and i would like to sort them in two
> categories.
> example,
>
> echo $row['name'] . '-' . $row['type'];
>
> // output:
>
> row 1 - files
>
add order by `type` to your sql statement, and then put something like
the following in your mysql loop:
// initialize $prevType above
if ($prevType !== $row['type'])
{
print "<hr>" . $row['type'] . "------<br>"; // Or whatever you
want the header to look like
}
$prevType = $row['type'];
That should do the trick.
--- End Message ---
--- Begin Message ---
Hello Sebastian,
Monday, January 10, 2005, 2:38:18 PM, you wrote:
S> if the $row['type'] is music i want to output an <hr> and the
S> results below it but below the files results.. makes sense? i
S> thought i remember doing this once using a dummy var but cant
S> remember how. i guess i could always run a second query, but would
S> like to avoid that.
As you loop through the recordset, just concatenate.
i.e.
while ($r=mysql_fetch_assoc($result))
{
if ($row['type'] == "Music")
$musicRows .= $row['name'] . '-' . $row['type'] . '<br>';
elseif ($row['type'] == "Files")
$fileRows .= $row['name'] . '-' . $row['type'] . '<br>';
elseif ($row['type'] == "Pictures")
$pictureRows .= $row['name'] . '-' . $row['type'] . '<br>';
}
echo 'FILES<br>-----<br>' . $fileRows . '<br><br>';
echo 'MUSIC<br>-----<br>' . $musicRows . '<br><br>';
echo 'PICTURES<br>--------<br>' . $pictureRows . '<br><br>';
I threw PICTURES in there just for GPs.
Cheers,
Leif Gregory
--
TB Lists Moderator (and fellow registered end-user)
PCWize Editor / ICQ 216395 / PGP Key ID 0x7CD4926F
Web Site <http://www.PCWize.com>
--- End Message ---
--- Begin Message ---
Sort when querying from database:
SELECT name, type FROM some_table ORDER BY type ASC, name ASC
----- Original Message -----
From: "Sebastian" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, January 11, 2005 5:38 AM
Subject: [PHP] sorting mysql results
I have a list of rows in the database and i would like to sort them in two
categories.
example,
echo $row['name'] . '-' . $row['type'];
// output:
row 1 - files
row 2 - files
row 3 - music
row 4 - files
I would like this output:
files
----------
row 1 - files
row 2 - files
row 4 - files
music
-----------
row 3 - music
if the $row['type'] is music i want to output an <hr> and the results
below
it but below the files results.. makes sense?
i thought i remember doing this once using a dummy var but cant remember
how. i guess i could always run a second query, but would like to avoid
that.
thanks for any help.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi,
Sometimes when I write a PHP-script and upload it to a ISP through password
protected FTP, the only way to write data to a folder is to run chmod 777
for that folder, I want to write (or save) a data to (e.g. file-upload,
flat-file-database). However, if I do so, I have been told, everyone can
write data to that file, which is a security risk. Is that true?
If I do so, is it right that anyone can write a data to that folder? E.g.
PHP-script that can reveal everything?
Regards,
SED
--- End Message ---
--- Begin Message ---
* Thus wrote SED:
> Hi,
>
> Sometimes when I write a PHP-script and upload it to a ISP through password
> protected FTP, the only way to write data to a folder is to run chmod 777
> for that folder, I want to write (or save) a data to (e.g. file-upload,
> flat-file-database). However, if I do so, I have been told, everyone can
> write data to that file, which is a security risk. Is that true?
yes, chmod'ing a directory to 777 is not the wisest thing to do.
If security is a major concern you can lock down you directory you
wish to have your files stored in on a shared server with some
context like:
Assuming you have your files stored in:
/www/domain.com/htaccess ; the docroot
/www/domain.com/special ; locked down files
/www/domain.com/ ; your ftp root
via ftp make a directory:
/www/domain.com/special/store/
chmod 777 /special/store
Then make a php script that does something like:
mkdir('/www/domain.com/special/store/files/');
chmod('/www/domain.com/special/store/files', 0700);
execute the script with the browser.
Now back in ftp:
chmod 755 /special/store
And wala.. your /www/domain.com/special/store/files is secure as
long as open_basedir is in effect.
HTH,
Curt
--
Quoth the Raven, "Nevermore."
--- End Message ---
--- Begin Message ---
--- End Message ---
--- Begin Message ---
zerof wrote:
John Holmes wrote:
What do you guys recommend for making thumbnails from uploaded images?
I know of the GD extension, Imagemagik and netpbm. Any other
recommendations or opinions on which of the above work best with PHP?
Thanks.
------
Good choice,
http://coppermine.sourceforge.net/demo/
Thank you for reading my question... oh wait...
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
* Thus wrote John Holmes:
> zerof wrote:
> >John Holmes wrote:
> >
> >>What do you guys recommend for making thumbnails from uploaded images?
> >>I know of the GD extension, Imagemagik and netpbm. Any other
> >>recommendations or opinions on which of the above work best with PHP?
> >>Thanks.
> >>
> >------
> >Good choice,
> >http://coppermine.sourceforge.net/demo/
>
> Thank you for reading my question... oh wait...
waits...
Curt
--
Quoth the Raven, "Nevermore."
--- End Message ---
--- Begin Message ---
> Please respond to the newsgroup and not to my personal email.
>
> <quote>Is it a file access/ownership thing?</quote>
>
> This is possible. Have you checked permissions for PHP user? My
> original question remains unanswered though and it is probably a better
> place to start...
>
> > extension_dir = "C:\php\extensions"
> >
> > where all the extension dlls reside.
> > All extensions are working and all dlls are loading properly,,
>
> What do you mean by this statement? How do you know this if you claim
> that cURL is not loading (it is an extension)... have you tried phpinfo()
?
>
What i mean by the statement is that when i tried to load other
modules(extensions u could say)
like php_cpdf,php_mhash...they are working...i mean i could see them as
enabled in phpinfo().
But when i load the curl extension i'm getting error.
Yes..i've tried phpinfo().
Its not displaying anything about cURL.
--- End Message ---
--- Begin Message ---
Hi,
I am new to this or any newsgroup in PHP, as well as PHP itself, so this
question is probably rather elementary. I have a form which on clicking
on the "Submit" button calls up a compiled program on the server that is
executed and writes output to a file. This file is then read by the PHP
script and passed on for other processes. When the page is first loaded,
it knows that the "Submit" button has not been clicked, and after clicking
the button it knows, which is of course what we want. The problem is that
subsequently it always thinks the button has been clicked, even if the
reload button on the browser has been clicked.
Here is a cut down version of the code, where for brevity I have removed
all inputs other than n:
<pre>
<form method="post" action="<?php print $_SERVER['PHP_SELF'] ?>">
Type in the following parameters:
<!-- Various other entries omitted such as a, i, e etc. -->
<input type="text" name="n" value="1000" size="6">
<input type="submit" name="form_sumbitted" value="Submit">
</form>
<p>
<?php
// Start of PHP code - Extract values from form.
/* Other values read */
$n=$_POST['n'];
// Pass the data from the form to lightcurve_csharp
$command="./lightcurve_csharp $a $i $e $lomega $bomega $lambda $n";
$result=`$command`;
$form_submitted=$_POST['form_sumbitted'];
if (isset($form_submitted)) {
if ($form_submitted) {
echo 'The form has been submitted<br>';
unset($form_submitted);
}
} else
echo 'The form has not been submitted<br>';
The input value of $n is picked up from $n=$_POST['n'] which has the
default of 1000, and I test that "Submit" has been clicked by looking at
the state of $form_sumbitted. Unfortunately this only works the first
time the page is loaded, and subsequently it is always flagged as set.
This is a test for only writing some text below the form if it has been
clicked. Subsequently, when the page is refreshed or is clicked again
with new data, the text below the form should disappear until the
calculations have been completed. The form is implimented at
http://proteus.as.arizona.edu/~csharp/sudarsky/lightcurvec.php .
I would be very grateful for some kind help on this.
Christopher Sharp
http://csharp.com
--- End Message ---
--- Begin Message ---
I am using PHP4.3.10 in WindowsXP. When I am trying to
use extension dlls e.g. php_xmlrpc.dll and when trying
to restart Apache2 Web Server, I am getting error
message as "UnKnows():Unable to load dynamic library
'./php_xmlrpc.dll.dll' - The specified module could
not be found". The DLL file php_xmlrpc.dll is already
exists in Windows/System32 directory. Can anybody help
me to how to use extension dlls.
regards,
Ranjan
__________________________________
Do you Yahoo!?
Yahoo! Mail - Easier than ever with enhanced search. Learn more.
http://info.mail.yahoo.com/mail_250
--- End Message ---
--- Begin Message ---
I am using PHP4.3.10 in WindowsXP. When I am trying to
use extension dlls e.g. php_xmlrpc.dll and when trying
to restart Apache2 Web Server, I am getting error
message as "UnKnows():Unable to load dynamic library
'./php_xmlrpc.dll.dll' - The specified module could
not be found". The DLL file php_xmlrpc.dll is already
exists in Windows/System32 directory. Can anybody help
me to how to use extension dlls.
regards,
Ranjan
__________________________________
Do you Yahoo!?
All your favorites on one personal page � Try My Yahoo!
http://my.yahoo.com
--- End Message ---
--- Begin Message ---
Ranjan K. Baisak wrote:
I am using PHP4.3.10 in WindowsXP. When I am trying to
use extension dlls e.g. php_xmlrpc.dll and when trying
to restart Apache2 Web Server, I am getting error
message as "UnKnows():Unable to load dynamic library
'./php_xmlrpc.dll.dll' - The specified module could
Transcription error? (.dll.dll)
not be found". The DLL file php_xmlrpc.dll is already
exists in Windows/System32 directory. Can anybody help
me to how to use extension dlls.
I set the php.ini to look for the extensions where you installed PHP
--
Lester Caine
-----------------------------
L.S.Caine Electronic Services
--- End Message ---
--- Begin Message ---
--- Lester Caine <[EMAIL PROTECTED]> wrote:
> I set the php.ini to look for the extensions where
> you installed PHP
>
I copied all dlls from PHP diectory to
WINDOWS/System32 directory and then it started
running. But still I am not sure how PHP picks up the
dll files. In my php.ini file I have set
extension_dir = C:\PHP4\extensions\
so from this directory all dlls should be picked up
then why I need to copy again all dll files from php
directiry to system32.
Onething I am assuming that Apache interpreter picks
up dll files from c:\windows\system32 directory and
php interpreter picks from C:\PHP4\extensions
directory. This is just my guess.
Weird ... not sure what exactly happens?
regards,
Ranjan
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail
--- End Message ---
--- Begin Message ---
Ranjan K. Baisak wrote:
I set the php.ini to look for the extensions where
you installed PHP
I copied all dlls from PHP diectory to
WINDOWS/System32 directory and then it started
running. But still I am not sure how PHP picks up the
dll files. In my php.ini file I have set
extension_dir = C:\PHP4\extensions\
so from this directory all dlls should be picked up
then why I need to copy again all dll files from php
directiry to system32.
Onething I am assuming that Apache interpreter picks
up dll files from c:\windows\system32 directory and
php interpreter picks from C:\PHP4\extensions
directory. This is just my guess.
Weird ... not sure what exactly happens?
Apache does not use the php modules!
There is no need to copy them to WINDOWS/System32
Apache is only complaining because PHP will not start.
Where have you actually got php.ini? the default is in c:\Windows
--
Lester Caine
-----------------------------
L.S.Caine Electronic Services
--- End Message ---
--- Begin Message ---
--- Lester Caine <[EMAIL PROTECTED]> wrote:
>
> Apache does not use the php modules!
> There is no need to copy them to WINDOWS/System32
> Apache is only complaining because PHP will not
> start.
> Where have you actually got php.ini? the default is
> in c:\Windows
Well php.ini file is in c:\windows directory. If I am
not copying all dlls to c:\windows\system32 directory
then duirng Apache service startup, it displays error
messages as I have mentioned in my first mail.
> Apache is only complaining because PHP will not
> start.
So should I assume that even of Apache displays error
messages but actually all dlls are loaded and I can
use them in my php files?
regards,
Ranjan
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
--- Begin Message ---
Ranjan K. Baisak wrote:
--- Lester Caine <[EMAIL PROTECTED]> wrote:
Apache does not use the php modules!
There is no need to copy them to WINDOWS/System32
Apache is only complaining because PHP will not
start.
Where have you actually got php.ini? the default is
in c:\Windows
Well php.ini file is in c:\windows directory. If I am
not copying all dlls to c:\windows\system32 directory
then duirng Apache service startup, it displays error
messages as I have mentioned in my first mail.
OK back up a step. So is PHP4 running if you do not enable the
php_xmlrpc module in php.ini?
Apache is only complaining because PHP will not
start.
So should I assume that even of Apache displays error
messages but actually all dlls are loaded and I can
use them in my php files?
I have seen some strange errors when things that a module relies on to
run are not available. If I don't have the firebird client installed,
php_interbase fails to load, and PHP will not start. I wonder if that
has something to do with it?
I'm on PHP5 now myself, and so that fixed a number if niggles which I
had with PHP4, so hopefully someone will wake up soon and provide the
real answer to the problem ;)
--
Lester Caine
-----------------------------
L.S.Caine Electronic Services
--- End Message ---
--- Begin Message ---
Hi there!
I'm looking for a workaround to carry out a feature similar to that I
could use any PHP function inside the replacement string in
eregi_replace (or ereg_replace).
I have a set of HTML code with some <h2>-headers. Now I should convert
all HTML headers to uppercase strings. As far as I know and have tested,
I can't use code like:
$newstr = eregi_replace("<h3>([a-z0-9 \.!\?]+)</h3>", strtoupper("\\1"));
How could I do that?
Ville
--- End Message ---
--- Begin Message ---
Ville Mattila wrote:
Hi there!
I'm looking for a workaround to carry out a feature similar to that I
could use any PHP function inside the replacement string in
eregi_replace (or ereg_replace).
I have a set of HTML code with some <h2>-headers. Now I should convert
all HTML headers to uppercase strings. As far as I know and have tested,
I can't use code like:
$newstr = eregi_replace("<h3>([a-z0-9 \.!\?]+)</h3>", strtoupper("\\1"));
How could I do that?
Ville
use preg_replace with the /e modifier
--- End Message ---
--- Begin Message ---
I *really* appreciate everybody's previous input. I may be a highly
experienced programmer, but am relatively new to PHP.
OK, I figured out what was going on. Google enough and read enough and
the light goes on finally.
The problem was not the "require_once" but a scoping problem.
Specifically, I was calling "require_once" /from within a function/.
Bad! Bad! Bad!
The included source file was also including other files... thus the
global class instance was just fine... it was simply hidden due to
scoping rules.
Yikes! I was really pulling my hair out when entire global functions
were "disappearing" due to the screwed up scope.
I finally figured out the problem in the "User Contributed Notes"
section of the PHP manual (http://www.php.net/language.variables.scope).
THANK YOU again...
--- End Message ---
--- Begin Message ---
Hello,
If I create form like this
<form name="form" action="##_URI_ROOT##/entity/edit.php?a=b" method="post">
<input type="hidden" name="action" value="modify" />
...
both arrays contain appropriate variables when submitted:
::: $_GET :::
Array
(
[a] => b
)
::: $_POST :::
Array
(
[action] => modify
...
)
Now what I am interested in is if this is valid behaviour regarding HTTP
specification and if other platforms support this interference of GET and
POST variables in request?
Thank your for your answers,
Bostjan
--- End Message ---
--- Begin Message ---
Is it just me or ... why on earth would you want to populate both GET and
POST arrays through this obscure way of coding ?
If you really have a form where you dont have a clue wether your data comes
from GET or POST, it should be way less effort to copy one array to another
or have a lookup function to return the given value.
/ Lars
----- Original Message -----
From: "Bostjan Skufca @ domenca.com" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Tuesday, January 11, 2005 5:42 PM
Subject: [PHP] $_GET & $_POST simultaneously
Hello,
If I create form like this
<form name="form" action="##_URI_ROOT##/entity/edit.php?a=b"
method="post">
<input type="hidden" name="action" value="modify" />
...
both arrays contain appropriate variables when submitted:
::: $_GET :::
Array
(
[a] => b
)
::: $_POST :::
Array
(
[action] => modify
...
)
Now what I am interested in is if this is valid behaviour regarding HTTP
specification and if other platforms support this interference of GET and
POST variables in request?
Thank your for your answers,
Bostjan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Browser history: I do not want it to contain any URIs to files which require
some sort of id variable passed.
Example:
1. http://www.entity.org/edit.php
(should produce an error or redirect to entity list)
2. http://www.entity.org/edit.php?id=1
(should display editing interface)
Now I really do not like to use redirects in case of errors. So I could
constantly use (2) second form of URI, even in POST requests.
But then, if I already have "id" in $_GET, why the redundancy of sending
another "id" to $_POST?
B.
On Tuesday 11 January 2005 09:48, you wrote:
> Is it just me or ... why on earth would you want to populate both GET and
> POST arrays through this obscure way of coding ?
>
> If you really have a form where you dont have a clue wether your data comes
> from GET or POST, it should be way less effort to copy one array to another
> or have a lookup function to return the given value.
>
> / Lars
>
> ----- Original Message -----
> From: "Bostjan Skufca @ domenca.com" <[EMAIL PROTECTED]>
> To: <[email protected]>
> Sent: Tuesday, January 11, 2005 5:42 PM
> Subject: [PHP] $_GET & $_POST simultaneously
>
> > Hello,
> >
> > If I create form like this
> > <form name="form" action="##_URI_ROOT##/entity/edit.php?a=b"
> > method="post">
> > <input type="hidden" name="action" value="modify" />
> > ...
> >
> > both arrays contain appropriate variables when submitted:
> > ::: $_GET :::
> >
> > Array
> > (
> > [a] => b
> > )
> >
> > ::: $_POST :::
> >
> > Array
> > (
> > [action] => modify
> > ...
> > )
> >
> > Now what I am interested in is if this is valid behaviour regarding HTTP
> > specification and if other platforms support this interference of GET and
> > POST variables in request?
> >
> > Thank your for your answers,
> > Bostjan
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
If I create the following 2 dimensional associative array:-
$insert["tab2"]["fields1"] = "value1";
$insert["tab1"]["fields2"] = "value2";
$insert["tab2"]["fields5"] = "value3";
$insert["tab1"]["fields7"] = "value4";
how do I do 2 levels of nested loop with the first level looping through the
first level of the array and the second nesting through the second. something
like:-
foreach( $insert as $table => $fields ) {
foreatch( $fields as $field => $value ) {
echo "update $table set $field = $value";
}
}
Regards,
Ben
--- End Message ---