php-general Digest 18 Apr 2004 23:57:03 -0000 Issue 2713
Topics (messages 183761 through 183784):
Re: Bookmark server
183761 by: Justin French
183763 by: Chris W
183764 by: Marek Kilimajer
Array Sorting Headaches
183762 by: Burhan Khalid
183768 by: Torsten Roehr
Re: why doesn't this work ?
183765 by: Pooya Eslami
183766 by: Robert Cummings
183767 by: Marek Kilimajer
183769 by: Daniel Clark
183770 by: Daniel Clark
183772 by: Dave G
session var problems
183771 by: Kathleen Ballard
183774 by: Daniel Clark
Re: addslashes vs. mysql_real_escape_string
183773 by: John W. Holmes
example from meloni not working
183775 by: Anthony Ritter
183776 by: Red Wingate
183777 by: Richard Harb
183778 by: Anthony Ritter
183779 by: Anthony Ritter
Regexp hyperlink
183780 by: Martin Visser
183781 by: Richard Harb
session var puzzle
183782 by: Kathleen Ballard
183783 by: Richard Harb
test, please ignore
183784 by: Michal Migurski
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 18/04/2004, at 10:35 AM, Chris W wrote:
So now I am out of ideas and was wondering if anyone here had any.
We're getting a little OT, but it's possible that a bookmarklet (a
JavaScript bookmark) installed on all browsers you use could act as the
method of grabbing the existing URL, and passing it to another URL
(your bookmark server) as a GET or POST var.
---
Justin French
http://indent.com.au
--- End Message ---
--- Begin Message ---
Justin French wrote:
On 18/04/2004, at 10:35 AM, Chris W wrote:
So now I am out of ideas and was wondering if anyone here had any.
We're getting a little OT, but it's possible that a bookmarklet (a
JavaScript bookmark) installed on all browsers you use could act as
the method of grabbing the existing URL, and passing it to another URL
(your bookmark server) as a GET or POST var.
that's not a viable option because the main idea of this bookmark server
is to be able to save URL's when I'm using computers I don't normally
use, like at a friends house or library or whereever.
Chris W
--- End Message ---
--- Begin Message ---
Chris W wrote:
Justin French wrote:
On 18/04/2004, at 10:35 AM, Chris W wrote:
So now I am out of ideas and was wondering if anyone here had any.
We're getting a little OT, but it's possible that a bookmarklet (a
JavaScript bookmark) installed on all browsers you use could act as
the method of grabbing the existing URL, and passing it to another URL
(your bookmark server) as a GET or POST var.
that's not a viable option because the main idea of this bookmark server
is to be able to save URL's when I'm using computers I don't normally
use, like at a friends house or library or whereever.
It's a matter of seconds to to grap the bookmarklet off your links
directory and put it into IE's favorites or Mozilla's bookmarks. There
has to be some kind of "installation" on the clients machine if you want
to make it simple.
--- End Message ---
--- Begin Message ---
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 :
Array
(
[$x] => Array
(
[0] => Array
(
[invoiceid] => 11842
[product] => myproduct
[domain] => foo.net
[expires] => February 28, 2004
)
[1] => Array
(
[invoiceid] => 10295
[product] => myotherproduct
[domain] => foo.net
[expires] => December 9, 2003
)
[2] => Array
(
[invoiceid] => 10202
[product] => product1
[domain] => foo.bar
[expires] => January 19, 2003
)
[3] => Array
(
[invoiceid] => 10005
[product] => product2
[domain] => foo.bar
[expires] => December 11, 2002
)
)
)
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.
Thanks again,
Burhan
--- End Message ---
--- Begin Message ---
"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
:
>
> Array
> (
>
> [$x] => Array
> (
> [0] => Array
> (
> [invoiceid] => 11842
> [product] => myproduct
> [domain] => foo.net
> [expires] => February 28, 2004
> )
>
> [1] => Array
> (
> [invoiceid] => 10295
> [product] => myotherproduct
> [domain] => foo.net
> [expires] => December 9, 2003
> )
>
> [2] => Array
> (
> [invoiceid] => 10202
> [product] => product1
> [domain] => foo.bar
> [expires] => January 19, 2003
> )
>
> [3] => Array
> (
> [invoiceid] => 10005
> [product] => product2
> [domain] => foo.bar
> [expires] => December 11, 2002
> )
>
> )
> )
>
> 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?
Regards, Torsten Roehr
>
> Thanks again,
> Burhan
--- End Message ---
--- Begin Message ---
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 ---
On Sun, 2004-04-18 at 10:27, 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?
You CAN embed PHP in .html files PROVIDED THAT YOUR WEBSERVER HAS
ENABLED SUPPORT. Since you do not have access to the webserver then it
is up to your provider to enable support. Generally they WILL NOT enable
support since the .html extension is reserved for non-scripted HTML
content. This means developers can lessen the load on the server by not
having regular HTML content pass through a script interpreter. Your
needs are in the minority, so it's "suck it in time" where you either
remove the dynamic part, change the extension, or start hosting your own
webserver.
Cheers,
Rob.
> "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 "
> > >>>>"; ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
--- End Message ---
--- Begin Message ---
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?
The server does not parse html files for php so that it does not waste
CPU on parsing files that don't have any php code.
Simply give that file php extension.
--- End Message ---
--- Begin Message ---
You have this as a xxx.php file right?
It has to have a .php extension for it to work.
>>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.
--- End Message ---
--- Begin Message ---
The web server is set up to see the .php file extension and pass the entire page to
the PHP engine for processing. Then the web server passes the
results back to the client's browser ( HTML, text, and images).
>>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?
--- End Message ---
--- Begin Message ---
> Why cannot I embed php in html files?
I'm relatively new to PHP, but I am fairly sure that it is
possible to have PHP embedded in .html files, as my web hosting service
accomplishes exactly that. I believe it's just some kind of setting in
Apache or somewhere else that you or your web hosting service can
configure.
On my web hosting service, the file can have a .html extension,
but there must be <?php ?> tags at the very beginning of the file, on
the very first line before absolutely any HTML code, including doctype
headings. If you want your PHP to work it's magic somewhere else in the
page, and not at the very beginning, it's no problem, just put some
harmless bit of code at the beginning, and then place whatever it is
that you really want to do within separate <?php ?> tags where you want
it.
Personally, because I work with software that generates
templates for all my web pages, I put the following code at the start of
every page:
<?php
session_start();
?>
I chose session_start as a command because I often need
sessions, and if there is a session, it needs to happen before the HTML
<head> tag anyway. If one of the pages based on my template doesn't have
a session, or even if it doesn't use any PHP at all, then the HTML
parser seems to just ignore the <?php ?> tags and whatever is in it and
output the .html file no problem.
Bottom line - speak to your web hosting service about
configuring .html files to be parsed by the PHP engine. If you're
running your own server, then you'll need to consult someone more
advanced than I. Also, I can't ensure there aren't any errors or
drawbacks to my advice, I'm just relaying how my web hosting service
seems to handle the issue.
Hope that helps.
--
Yoroshiku!
Dave G
[EMAIL PROTECTED]
--- End Message ---
--- Begin Message ---
Dear list,
I am trying to set a simple session variable on PageA.
$_SESSION['CategoryID'] = intval($Data['ID']);
if I print after setting the value on PageA, I will
get the expected ID number.
go on to PageB and $_SESSION['CategoryID'] is '0'.
If I hard code in a value for $_SESSION['CategoryID']
on PageA, it prints correctly on PageB.
If I set $Test = 462 and then
$_SESSION['CategoryID'] = intval($Test);
on PageA, it prints correctly on PageB.
Does anyone have any ideas?
Kathleen
--- End Message ---
--- Begin Message ---
Do yo have have start_session() on every page to before you can read session variables?
>>Dear list,
>>I am trying to set a simple session variable on PageA.
>>
>>$_SESSION['CategoryID'] = intval($Data['ID']);
>>
>>if I print after setting the value on PageA, I will
>>get the expected ID number.
>>
>>go on to PageB and $_SESSION['CategoryID'] is '0'.
>>
>>If I hard code in a value for $_SESSION['CategoryID']
>>on PageA, it prints correctly on PageB.
>>
>>If I set $Test = 462 and then
>>$_SESSION['CategoryID'] = intval($Test);
>>on PageA, it prints correctly on PageB.
>>
>>Does anyone have any ideas?
>>
>>Kathleen
--- End Message ---
--- Begin Message ---
Richard Davey wrote:
Does mysql_real_escape_string (or mysql_escape_string) do anything
extra that addslashes() doesn't? In the examples in the manual it is
just used to escape the ' character, but that is exactly what
addslashes() will do anyway.
real_escape_string() takes the current character set into consideration
when it escapes characters. Probably 99% of the time it's going to
behave like addslashes(), but it's still good to use it because you're
letting the database determine what needs to be escaped rather than just
assuming it's only the characters covered by addslashes().
Is mysql_real_escape_string tolerant of magic quotes? i.e. will you
end up with double-quoted strings like: "it\\'s a lovely day" if you
call it too many times?
Yes, you'll end up with extra backslashes. If you ever see "it\'s a
lovely day" in your database, then you're escaping the string more than
once. You shouldn't see escape characters in your database or have to
stripslashes() anything coming out of your database (unless you have
magic_quotes_runtime() enabled).
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
A basic ht counter script from Meloni's book on mysql (page 318).
Not working for me.
Every time I load the page the counter stays at zero.
Thanks for help.
TR
..................
<?
$page_name="test1";
$db=mysql_connect("localhost","root",'mypass");
mysql_select_db("sitename");
$sql = "UPDATE test_track SET hits = hits + 1 WHERE page_name =
'$page_name';
$sql2="SELECT hits FROM test_track WHERE page_name='$page_name'";
$res=mysql_query($sql2);
$hits = mysql_result($res,0,'hits');
?>
<html>
<body>
<h1>You have been counted.</h1>
<p>
The current number is <? echo "$hits"; ?></p>
</body>
</html>
.........
// mysql SCHEMA
CREATE TABLE test_track(
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
page_name VARCHAR(50),
hits INT
);
INSERT INTO test_track VALUES(1,'test1',0);
........
--- End Message ---
--- Begin Message ---
Execute $sql :)
-- red
-----Ursprüngliche Nachricht-----
Von: Anthony Ritter [mailto:[EMAIL PROTECTED]
Gesendet: Sunday, April 18, 2004 7:42 PM
An: [EMAIL PROTECTED]
Betreff: [PHP] example from meloni not working
A basic ht counter script from Meloni's book on mysql (page 318).
Not working for me.
Every time I load the page the counter stays at zero.
Thanks for help.
TR
..................
<?
$page_name="test1";
$db=mysql_connect("localhost","root",'mypass");
mysql_select_db("sitename");
$sql = "UPDATE test_track SET hits = hits + 1 WHERE page_name =
'$page_name';
$sql2="SELECT hits FROM test_track WHERE page_name='$page_name'";
$res=mysql_query($sql2);
$hits = mysql_result($res,0,'hits');
?>
<html>
<body>
<h1>You have been counted.</h1>
<p>
The current number is <? echo "$hits"; ?></p>
</body>
</html>
.........
// mysql SCHEMA
CREATE TABLE test_track(
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
page_name VARCHAR(50),
hits INT
);
INSERT INTO test_track VALUES(1,'test1',0);
........
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
From what I've seen you didn't actually transmit the first query to
the database.
You assigned the query string to the variable $sql ... but didn't
submit with:
mysql_query($sql);
hth
richard
Sunday, April 18, 2004, 7:41:47 PM, thus was written:
> A basic ht counter script from Meloni's book on mysql (page 318).
> Not working for me.
> Every time I load the page the counter stays at zero.
> Thanks for help.
> TR
> ..................
> <?
> $page_name="test1";
> $db=mysql_connect("localhost","root",'mypass");
> mysql_select_db("sitename");
> $sql = "UPDATE test_track SET hits = hits + 1 WHERE page_name =
> '$page_name';
> $sql2="SELECT hits FROM test_track WHERE page_name='$page_name'";
> $res=mysql_query($sql2);
> $hits = mysql_result($res,0,'hits');
?>>
> <html>
> <body>
> <h1>You have been counted.</h1>
> <p>
> The current number is <? echo "$hits"; ?></p>
> </body>
> </html>
> .........
> // mysql SCHEMA
> CREATE TABLE test_track(
> id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
> page_name VARCHAR(50),
> hits INT
> );
> INSERT INTO test_track VALUES(1,'test1',0);
> ........
--- End Message ---
--- Begin Message ---
Thank you.
TR
--- End Message ---
--- Begin Message ---
Thank you.
TR
--- End Message ---
--- Begin Message ---
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 ---
--- Begin Message ---
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 ---
--- Begin Message ---
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
--- End Message ---
--- Begin Message ---
Hi,
As I have no idea what those var contain ..
what does a print_r() of it give you?
print it right when you assign it to the session var to check if
it actually contains a value.
like:
print_r($Data['ID']);
and maybe even
print_r(intval($Data['ID']));
I suspect that this $Data['ID'] is empty from the start - otherwise
you ought to have something in your session var.
Richard
Monday, April 19, 2004, 12:46:02 AM, thus was written:
> 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
--- End Message ---
--- Begin Message ---
---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html
--- End Message ---