php-general Digest 19 Apr 2004 12:20:42 -0000 Issue 2714
Topics (messages 183785 through 183799):
Re: session var puzzle
183785 by: Tom Rogers
183787 by: Larry Brown
Problems compiling a DSO in BSD/OS 5.1
183786 by: The Doctor
Re: why doesn't this work ?
183788 by: Andy Ladouceur
Re: Array Sorting Headaches
183789 by: Burhan Khalid
183791 by: Torsten Roehr
183793 by: Burhan Khalid
183794 by: Torsten Roehr
183799 by: Burhan Khalid
Re: Why are Session Variables carried over into a brand new browser window?
183790 by: Rob Adams
Re: php accelerator for php5rc1 ?
183792 by: David Herring
183795 by: Elfyn McBratney
183797 by: Thomas Seifert
C or C++
183796 by: Brent Clark
Re: Regexp hyperlink
183798 by: Martin Visser
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 ---
Hi,
Monday, April 19, 2004, 8:46:02 AM, you wrote:
KB> Dear list,
KB> I am sorry for the second posting, but this is going
KB> to drive me to drink something other than lattes!
KB> I have one page, index.php. when it calls mod_sub, a
KB> directory type of page is printed. Here I am trying
KB> to set a session var of the most recently selected
KB> category to allow the user to return the to same place
KB> in the directory.
KB> when I do this:
KB> $_SESSION['CategoryID'] = 230; in mod_sub
KB> then in mod_profile:
KB> print($_SESSION['CategoryID']);
KB> will print 230
KB> when I do this:
KB> $Tmp = 230;
KB> $_SESSION['CategoryID'] = $Tmp; in mod_sub
KB> in mod_profile:
KB> print($_SESSION['CategoryID']);
KB> will print 230
KB> BUT, when I do this:
KB> $_SESSION['CategoryID'] = $Data['ID']; in mod_sub
KB> $_SESSION['CategoryID'] = intval($Data['ID']);
KB> in mod_profile:
KB> print($_SESSION['CategoryID']);
KB> will print '' and 0
KB> I am setting several other session variables
KB> throughout the code without any unexpected behavior.
KB> I have even tried changing the index to something odd
KB> in case I am resetting 'CategoryID' somewhere and
KB> forgotten it. But no matter what I try, once I set it
KB> "= $Data['ID']" I get the odd result.
KB> BTW, if I print $_SESSION['CategoryID'] from mod_sub
KB> right after setting, it holds the expected value.
KB> This is really frustrating, I must be missing
KB> something basic about the way session vars can be set.
KB> Kathleen
put this at the top of each page and see if you get any undefined
variables warnings as it may be a problem of variable scope
error_reporting(E_ALL);
--
regards,
Tom
--- End Message ---
--- Begin Message ---
In the last pair of examples where it fails, you know you are first
assigning the value of $Data['ID'] to the $_SESSION['CategoryID'] and the
over-writing that value with the value of intval($Data['ID'])? Why are you
assigning $Data['ID'] to it if you are going to overwrite it? If those
other tests work then I doubt that it is a session problem. I'd
double-check to make sure that $Data['ID'] is holding a reasonable value.
-----Original Message-----
From: Kathleen Ballard [mailto:[EMAIL PROTECTED]
Sent: Sunday, April 18, 2004 6:46 PM
To: [EMAIL PROTECTED]
Subject: [PHP] session var puzzle
Dear list,
I am sorry for the second posting, but this is going
to drive me to drink something other than lattes!
I have one page, index.php. when it calls mod_sub, a
directory type of page is printed. Here I am trying
to set a session var of the most recently selected
category to allow the user to return the to same place
in the directory.
when I do this:
$_SESSION['CategoryID'] = 230; in mod_sub
then in mod_profile:
print($_SESSION['CategoryID']);
will print 230
when I do this:
$Tmp = 230;
$_SESSION['CategoryID'] = $Tmp; in mod_sub
in mod_profile:
print($_SESSION['CategoryID']);
will print 230
BUT, when I do this:
$_SESSION['CategoryID'] = $Data['ID']; in mod_sub
$_SESSION['CategoryID'] = intval($Data['ID']);
in mod_profile:
print($_SESSION['CategoryID']);
will print '' and 0
I am setting several other session variables
throughout the code without any unexpected behavior.
I have even tried changing the index to something odd
in case I am resetting 'CategoryID' somewhere and
forgotten it. But no matter what I try, once I set it
"= $Data['ID']" I get the odd result.
BTW, if I print $_SESSION['CategoryID'] from mod_sub
right after setting, it holds the expected value.
This is really frustrating, I must be missing
something basic about the way session vars can be set.
Kathleen
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Can someone tell me where to start?
I was able to compile a DSO in BSD/OS 4.3.1 . I try to use the same setup
in BSD/OS 5.1 and not even a .so would show up. HELP!!
--
Member - Liberal International On 11 Sept 2001 the WORLD was violated.
This is [EMAIL PROTECTED] Ici [EMAIL PROTECTED]
Society MUST be saved! Extremists must dissolve.
Time to see the eternal relegation of Man U, Liverpool, Everton and Millwall
--- End Message ---
--- Begin Message ---
Okay, what you can do is try use an .htaccess file (providing your host
allows them) to make the PHP engine parse .html files.
Create a file titled ".htaccess" with the following contents:
AddType application/x-httpd-php .php .php3 .html .htm
Upload it to the same folder that the .html file is in, and see if it works.
(Oh, and if you are using WS_FTP LE, be sure to add '-al' in the white
box on the right [Remote] vertical line of buttons so that you are able
to view the .htaccess file in the folder once uploaded.)
Cheers,
Andy
Pooya Eslami wrote:
Yes, the server supports php, and I don't want to make it into a php file
because its a big html file and I just need this little script on it. Why
cannot I embed php in html files?
"Andy Ladouceur" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
It's already been mentioned, but you do need to ensure you are using a
.php extension on the file. Also, forgive me if this has already been
covered, but are you sure the server even supports PHP?
Try creating a new file with:
<?php
phpinfo();
?>
And save it as something.php, check and see if it returns a table full
of information or not.
Andy
Pooya Eslami wrote:
I put this in the body of an html file:
<?php
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && eregi('\.html$', $file)) {
echo "<li><a href=\"$file\"><font color=\"#CC0000\">$file</
font></a></li><br>";
}
}
closedir($handle);
}
echo "</ul>";
?>
the output page contains :
$file
"; } } closedir($handle); } echo "
"; ?>
I don't understand why.
"Daniel Clark" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Can you post the code and error.
I took out the scrip tags and put in <?php in the beginning and ?> at
the
end, but it returns this:
$file
"; } } closedir($handle); } echo "
"; ?>
--- End Message ---
--- Begin Message ---
Torsten Roehr wrote:
"Burhan Khalid" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Greetings everyone :
Having a hard time with this one. I have a multi-dim array
$foo[$x][$y]['key'], where $x and $y are numeric. Here is some sample data
[ snipped ]
I need to filter the results so that I get the latest expiry date for
each product. The expires field actually contains a timestamp. So for
the sample array above, the resultant array would have only keys 0 and
2, filtering out all the rest. There are around 180+ main entries, with
any number of sub entries, but each sub entry has the same four keys.
Any ideas? Getting a rather large headache mulling over this.
Hi,
as your structure is always the same you could just loop through all
elements and subelements and use unset() to remove the unwanted array
elements:
foreach ($foo as $key => $value) {
foreach ($value as $subkey => $subvalue) {
// put your check logic here
if ($foo[$key][$subkey]['expires'] == '') {
unset($foo[$key][$subkey]);
}
}
}
What do you think?
Well this is what I have right now, but the problem is the logic which
checks to see for each domain which is the last expired date. I have
three nested for loops right now, and not getting anywhere :(
--- End Message ---
--- Begin Message ---
"Burhan Khalid" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Torsten Roehr wrote:
>
> > "Burhan Khalid" <[EMAIL PROTECTED]> wrote in message
> > news:[EMAIL PROTECTED]
> >
> >>Greetings everyone :
> >>
> >> Having a hard time with this one. I have a multi-dim array
> >>$foo[$x][$y]['key'], where $x and $y are numeric. Here is some sample
data
> >
> [ snipped ]
>
> >>I need to filter the results so that I get the latest expiry date for
> >>each product. The expires field actually contains a timestamp. So for
> >>the sample array above, the resultant array would have only keys 0 and
> >>2, filtering out all the rest. There are around 180+ main entries, with
> >>any number of sub entries, but each sub entry has the same four keys.
> >>
> >>Any ideas? Getting a rather large headache mulling over this.
> >
> >
> > Hi,
> >
> > as your structure is always the same you could just loop through all
> > elements and subelements and use unset() to remove the unwanted array
> > elements:
> >
> > foreach ($foo as $key => $value) {
> >
> > foreach ($value as $subkey => $subvalue) {
> >
> > // put your check logic here
> > if ($foo[$key][$subkey]['expires'] == '') {
> >
> > unset($foo[$key][$subkey]);
> > }
> > }
> > }
> >
> > What do you think?
>
> Well this is what I have right now, but the problem is the logic which
> checks to see for each domain which is the last expired date. I have
> three nested for loops right now, and not getting anywhere :(
Maybe it works if you put the expires value in a seperate array, sort it and
then you can get the key of the first one and use unset():
foreach ($foo as $key => $value) {
$tempArray = array();
foreach ($value as $subkey => $subvalue) {
// add expires value only to the temporary array for
sorting
$tempArray[$subkey] = $foo[$key][$subkey]['expires'];
}
// sort array by value descending
arsort($tempArray);
// get first (and therefore highest timestamp) key/value pair
$firstEntry = each($tempArray);
$notneededSubkey = $firstEntry['key'];
// now unset the array value with the not needed subkey
unset($foo[$key][$notneededSubkey]);
}
Have not tried it but may work. Hope you see my point.
Regards, Torsten Roehr
--- End Message ---
--- Begin Message ---
Torsten Roehr wrote:
"Burhan Khalid" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Torsten Roehr wrote:
"Burhan Khalid" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Greetings everyone :
Having a hard time with this one. I have a multi-dim array
$foo[$x][$y]['key'], where $x and $y are numeric. Here is some sample
data
[ snipped ]
I need to filter the results so that I get the latest expiry date for
each product. The expires field actually contains a timestamp. So for
the sample array above, the resultant array would have only keys 0 and
2, filtering out all the rest. There are around 180+ main entries, with
any number of sub entries, but each sub entry has the same four keys.
Any ideas? Getting a rather large headache mulling over this.
Hi,
as your structure is always the same you could just loop through all
elements and subelements and use unset() to remove the unwanted array
elements:
foreach ($foo as $key => $value) {
foreach ($value as $subkey => $subvalue) {
// put your check logic here
if ($foo[$key][$subkey]['expires'] == '') {
unset($foo[$key][$subkey]);
}
}
}
What do you think?
Well this is what I have right now, but the problem is the logic which
checks to see for each domain which is the last expired date. I have
three nested for loops right now, and not getting anywhere :(
Maybe it works if you put the expires value in a seperate array, sort it and
then you can get the key of the first one and use unset():
foreach ($foo as $key => $value) {
$tempArray = array();
foreach ($value as $subkey => $subvalue) {
// add expires value only to the temporary array for
sorting
$tempArray[$subkey] = $foo[$key][$subkey]['expires'];
}
// sort array by value descending
arsort($tempArray);
// get first (and therefore highest timestamp) key/value pair
$firstEntry = each($tempArray);
$notneededSubkey = $firstEntry['key'];
// now unset the array value with the not needed subkey
unset($foo[$key][$notneededSubkey]);
}
Have not tried it but may work. Hope you see my point.
Well, it does some sorting, but not quite what I'm after :(
I've managed to get the list so that all the (sub) entries are sorted in
the correct order. Now its just a matter of finding the highest expire
date for /each/ domain, and delete the other entries for that domain.
So, in the end, all that's left is one entry per domain, with its latest
expire date.
Hopefully this makes it a bit clearer.
--- End Message ---
--- Begin Message ---
> Well, it does some sorting, but not quite what I'm after :(
>
> I've managed to get the list so that all the (sub) entries are sorted in
> the correct order. Now its just a matter of finding the highest expire
> date for /each/ domain, and delete the other entries for that domain.
> So, in the end, all that's left is one entry per domain, with its latest
> expire date.
>
> Hopefully this makes it a bit clearer.
OK, so it's just the other way round - I see. Instead of deleting the entry
with the highest expiry date we delete all the others:
foreach ($foo as $key => $value) {
$tempArray = array();
foreach ($value as $subkey => $subvalue) {
// add expires value only to the temporary array for
sorting
$tempArray[$subkey] = $foo[$key][$subkey]['expires'];
}
// sort array by value descending
arsort($tempArray);
/* new stuff starts here */
// remove the entry with the latest expiry (the first array
element)
array_push($tempArray);
// now unset all remaining/not needed entries
foreach ($tempArray as $tempKey => $tempValue) {
unset($foo[$key][$tempKey]);
}
}
By the way, isn't there a way to filter this stuff BEFORE or WHILE the whole
array is created?
Regards, Torsten
--- End Message ---
--- Begin Message ---
Torsten Roehr wrote:
Well, it does some sorting, but not quite what I'm after :(
I've managed to get the list so that all the (sub) entries are sorted in
the correct order. Now its just a matter of finding the highest expire
date for /each/ domain, and delete the other entries for that domain.
So, in the end, all that's left is one entry per domain, with its latest
expire date.
Hopefully this makes it a bit clearer.
OK, so it's just the other way round - I see. Instead of deleting the entry
with the highest expiry date we delete all the others:
foreach ($foo as $key => $value) {
$tempArray = array();
foreach ($value as $subkey => $subvalue) {
// add expires value only to the temporary array for
sorting
$tempArray[$subkey] = $foo[$key][$subkey]['expires'];
}
// sort array by value descending
arsort($tempArray);
/* new stuff starts here */
// remove the entry with the latest expiry (the first array
element)
array_push($tempArray);
// now unset all remaining/not needed entries
foreach ($tempArray as $tempKey => $tempValue) {
unset($foo[$key][$tempKey]);
}
}
By the way, isn't there a way to filter this stuff BEFORE or WHILE the whole
array is created?
Thanks for the help. I'll give that snippet a try and see what comes out.
The array is a result of a rather nasty SQL statement running against a
database (which I didn't design). Unfortunately, the way the database is
designed, its very difficult to extract the domain information.
I am in the process of rewriting the entire thing as a Java application,
hopefully that will make things a bit clearer, since I'll also be
refactoring the database schema.
Many thanks,
Burhan
--- End Message ---
--- Begin Message ---
"Bob Bruce - Programmer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> <A target="blank"
>
href="http://www.themuralsofwinnipeg.com/Mpages/index.php?action=gotomural&m
> uralid=179">
>
> so this opens a new browser window, but it is inheriting the session
values
> from the browser window that called it and is causing problems in the new
> window. When I open a new browser window shouldn't it start a whole new
> session and not get anything from the previous browser.
What browser are you using? I've seen this topic come up before, and it
tends to be an issue with the client rather than the server. The client I
use happens to avoid sending the session cookie from a new window, so this
doesn't generally happen to me, while other clients default to sending the
session cookie.
BTW - cool site.
-- Rob
--- End Message ---
--- Begin Message ---
Hi Thomas,
Thanks for the correction.
My current undertanding is that zend-acelerator, phpa, turck-mmache and
apc do not
support PHP5.0rc1 ? Is there any accelerator that does ?
Thx dave
Thomas Seifert wrote:
On Sat, 17 Apr 2004 19:01:21 +0100 [EMAIL PROTECTED] (David Herring) wrote:
The latest Zend optimiser - 3.60 does not support php 5 - is there any
alternative accelerators which do ?
uhm, afaik the "optimiser" is not an accelerator, more kind of a loader for
encrypted files.
You would have to use the zend-accelerator, phpa, turck-mmcache, apc or similar
products.
thomas
--
David Herring
---
Netfm Ltd
T: 07092 140694
M: 07766 086179
F: 07092 337656
--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello David
On Monday 19 Apr 2004 08:34, David Herring wrote:
> Hi Thomas,
>
> Thanks for the correction.
>
> My current undertanding is that zend-acelerator, phpa, turck-mmache and
> apc do not
> support PHP5.0rc1 ? Is there any accelerator that does ?
>
Although Turck MMCache doesn't yet officially support PHP5, it works (very
well here). If your able to test it with PHP5 and send bugs when/if you get
any problems, then it might be ready sooner. :)
Elfyn
> Thomas Seifert wrote:
> >On Sat, 17 Apr 2004 19:01:21 +0100 [EMAIL PROTECTED] (David Herring)
wrote:
> >>The latest Zend optimiser - 3.60 does not support php 5 - is there any
> >>alternative accelerators which do ?
> >
> >uhm, afaik the "optimiser" is not an accelerator, more kind of a loader
> > for encrypted files.
> >You would have to use the zend-accelerator, phpa, turck-mmcache, apc or
> > similar products.
- --
Elfyn McBratney, EMCB
mailto:[EMAIL PROTECTED]
http://www.emcb.co.uk/
PGP Key ID: 0x456548B4
PGP Key Fingerprint:
29D5 91BB 8748 7CC9 650F 31FE 6888 0C2A 4565 48B4
Error: quote_machine(): Dry humour detected.
>> ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ <<
<< ~ Linux london 2.6.5-emcb-243 #2 i686 GNU/Linux ~ >>
>> ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ <<
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAg6a1aIgMKkVlSLQRAoPOAKCKtRqolmvH7zWWIgvQCSjCd1jdGgCgnHkC
/w/ofhJWCaox6YmuCT2NUh0=
=S7tI
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
Hi David,
I'm not quite sure if its worth the trouble to officially support
a php-version which is not yet stable.
I remember that, at least, turck-mmcache has unofficial support for php5.
thomas
David Herring ([EMAIL PROTECTED]) schrieb:
>
>
> Hi Thomas,
>
> Thanks for the correction.
>
> My current undertanding is that zend-acelerator, phpa, turck-mmache and
> apc do not
> support PHP5.0rc1 ? Is there any accelerator that does ?
>
> Thx dave
>
--- End Message ---
--- Begin Message ---
Hi All
Just a quick question, is PHP written in C or C++.
Kind Regards
Brent Clark
--- End Message ---
--- Begin Message ---
Thanks alot!
It's indeed an ingenious way of doing it!
Martin
Richard Harb schreef:
A while ago I've been looking at some piece of code of the tikiwiki
project to see how they did some of their magic...
Basically they run through the whole text and if they found something
that was translated they made a hash and replaced the actual text with
it and stored the link in an assoc array.
when all occurrences of translatable elements were found they ran
through the array and replaced all hashes with the translated text.
I found that to be quite an ingenious way of doing it ...
Then again it might have misread/misinterpreted the code :)
Richard
Sunday, April 18, 2004, 10:08:51 PM, thus was written:
I can't figure out how to do this.
I've four different methods for changing a piece of text into a hyperlink.
the text:
[link=www.hotmail.com]hotmail[/link]
[link=http://www.hotmail.com]hotmail[/link] www.hotmail.com
http://www.hotmail.com
what it should become (offcourse in HTML it will change to a real
hyperlink):
<a href="http://www.hotmail.com" target="_blank">hotmail</a> <a
href="http://www.hotmail.com" target="_blank">hotmail</a> <a
href="http://www.hotmail.com" target="_blank">www.hotmail.com</a> <a
href="http://www.hotmail.com"
target="_blank">http://www.hotmail.com</a>
i've got this regexps, at this point there are two different ones and I
would like to combine them (not really necessary):
1.
$text = str_replace("[link=http://", "[link=", $text);
$text = preg_replace("/\[link=(.+)\](.+)\[\/link\]/U", "<a
href=\"http://\\1\" target=\"_blank\">\\2</a>", $text);
2.
$text =
preg_replace("!(((http(s?)://)|(www|home\.))([-a-z0-9.]{2,}\.[a-z]{2,4}(:[0-9]+)?)((/([^\s]*[^\s.,\"'])?)?)((\?([^\s]*[^\s.,\"'])?)?))!i",
"<a href=\"http\\4://\\5\\6\\8\\9\" target=\"_blank\">\\1</a>", $text);
// I copied this one, maybe someone knows a better one?
the problem is that it's replaced a second time resulting in this:
<a href="<a href="http://www.hotmail.com
target="_blank">>http://www.hotmail.com</a>]hotmail[/link] [link=<a
href="http://www.hotmail.com" target="_blank">www.hotmail.com</a>"
target="_blank">>hotmail</a> <a href="http://www.hotmail.com"
target="_blank">>www.hotmail.com</a> <a href="http://www.hotmail.com"
target="_blank">>http://www.hotmail.com</a>
the last two (without the [link=] part) are working
--- End Message ---