[PHP] Re: Why are Session Variables carried over into a brand new browser window?

2004-04-18 Thread Torsten Roehr
Bob Bruce - Programmer [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 This is my first posting to this group, so I am not familiar
 with any special etiquette for it, please bear with me. . .

 I maintain the PHP code for the website for the murals of Winnipeg and
 have found a situation where I have a session open with the state of
 the user's search results saved in the session and link to a location
 with the following link:

 A target=blank

href=http://www.themuralsofwinnipeg.com/Mpages/index.php?action=gotomuralm
 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.

You can solve this problem by not working with cookies and instead
forwarding the sessionID with the URL:

A target=blank
href=http://www.themuralsofwinnipeg.com/Mpages/index.php??= SID;
?action=gotomuralmuralid=179

So if you open a new page WITHOUT forwarding the sessionID a new session
will be started.

See the part named Passing the Session ID on the following manual page to
see how to do it:
http://de2.php.net/session

Regards,

Torsten Roehr


 Thanks in advance for your help,

 Bob Bruce,
 Winnipeg, Manitoba
 Canada

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Bookmark server

2004-04-18 Thread PHP Email List
 I am planning on writing a bookmark server in php.  The idea is I will
 have a database that stores all my internet favorites on a web server
 some where, so if I am doing some web browsing away from home and find a
 site I want to save, I can go to my bookmark server and save the url
 there.  Now for the part I can't figure out an easy way to do.  I want
 to have it so if I am looking at a page I want to save I can type in a
 nice short url for my bookmark server and it will some how be able to
 know where I just came from and have the form fields for URL and
 description already filled in for me.  Then I just have to tell it what
 category to save the bookmark in.
 First I thought the _SERVER[HTTP_REFERER] variable, but that only
 works if you click on a link and since every web page I want to save
 won't have a link to my bookmark server that won't work.
 Then I thought I could use the history array with javascript, but that
 only works if your script is signed and I don't want to go there.

 So now I am out of ideas and was wondering if anyone here had any.

Why not just copy the url from the address bar, then go to your site and use
that text box (form field) you were talkin about having and paste the url
then click submit.

Then it's saved in your nice little url holder / bookmark warehouse!  :)

Then your not trying to do anything fancy. Like you know, cook you
breakfast in the morning, or say pull every email you have out and read them
and toss the ones you don't want while systematically forecasting your stock
market results of your IRA from the night before.

Wolf
HTH  :-P

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] addslashes vs. mysql_real_escape_string

2004-04-18 Thread Richard Davey
Hi,

I just finished reading Chris Shiflett's article in this months php|a
about SQL injection and have a question I can't seem to find answered
anywhere:

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.

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?

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Array Problem

2004-04-18 Thread Don Read

On 16-Apr-2004 Flavio Fontana wrote:
 Hi
 
 I have i Problem i got a variable a=2351 now i need to create an
 array out of this variable 
 a[0]=1
 a[1]=3
 a[2]=5
 a[3]=1
 
 I have an idea to use the modulo function an do some Math but im sure
 there is a nicer way of solving my prob
 

$a = preg_split('||', $a, -1, PREG_SPLIT_NO_EMPTY);

Regards,
-- 
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



php-general Digest 18 Apr 2004 11:55:07 -0000 Issue 2712

2004-04-18 Thread php-general-digest-help

php-general Digest 18 Apr 2004 11:55:07 - Issue 2712

Topics (messages 183746 through 183760):

Re: why doesn't this work ?
183746 by: Daniel Clark
183754 by: Pooya Eslami
183756 by: Andy Ladouceur

Removing line breaks...
183747 by: Russell P Jones
183749 by: -{ Rene Brehmer }-
183750 by: Daniel Clark

Bookmark server
183748 by: Chris W
183758 by: PHP Email List

Why are Session Variables carried over into a brand new browser window?
183751 by: Bob Bruce - Programmer
183752 by: Travis Low
183755 by: Greg Donald
183757 by: Torsten Roehr

Re: Array Problem
183753 by: Tom Rogers
183760 by: Don Read

addslashes vs. mysql_real_escape_string
183759 by: Richard Davey

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]


--
---BeginMessage---
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---
---BeginMessage---
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 lia href=\$file\font color=\#CC\$file/

font/a/libr;
   }
   }
   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---
---BeginMessage---
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 lia href=\$file\font color=\#CC\$file/
font/a/libr;
   }
   }
   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---
---BeginMessage---
How do i turn this...

[br]
  [b]My Title [/b]
[br]

into

[br][b]My Title[/b][br]


--- I just need to have line breaks removed basically...

any ideas?

Russ Jones
---End Message---
---BeginMessage---
str_replace(\n,'',$string);

don't think it'd be any faster with the regex ones...

Rene

At 01:18 18-04-2004, Russell P Jones wrote:
How do i turn this...

[br]
  [b]My Title [/b]
[br]
into

[br][b]My Title[/b][br]

--- I just need to have line breaks removed basically...

any ideas?

Russ Jones
--
Rene Brehmer
aka Metalbunny
~ If you don't like what I have to say ... don't read it ~

http://metalbunny.net/
References, tools, and other useful stuff...
Check out the new Metalbunny forums @ http://forums.metalbunny.net/
---End Message---
---BeginMessage---
str_replace( $line, '\n', '')

http://us2.php.net/manual/en/function.str-replace.php

How do i turn this...

[br]
  [b]My Title [/b]
[br]

into

[br][b]My Title[/b][br]


--- I just need to have line breaks removed basically...

any ideas?
---End Message---
---BeginMessage---
I am planning on writing a bookmark server in php.  The idea is I will 
have a database that stores all my internet favorites on a web server 
some where, so if I am doing some web browsing away from home and find a 
site I want to save, I can go to my bookmark server and save the url 
there.  Now for the part I can't figure out an easy way to do.  I want 
to have it so if I am looking at a page I want to save I can type in a 
nice short url for my bookmark server and it will some how be able to 
know where I just came from and have the form fields for URL and 
description already filled in for me.  Then I just have to tell it what 
category to save the bookmark in.
First I thought the _SERVER[HTTP_REFERER] variable, but that only 
works if you click on a link and since every web page I want to save 
won't have a link to my bookmark server that won't work.
Then I thought 

Re: [PHP] Bookmark server

2004-04-18 Thread Justin French
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Array Sorting Headaches

2004-04-18 Thread Burhan Khalid
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Bookmark server

2004-04-18 Thread Chris W
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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Bookmark server

2004-04-18 Thread Marek Kilimajer
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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] why doesn't this work ?

2004-04-18 Thread Pooya Eslami
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 lia href=\$file\font color=\#CC\$file/
 
  font/a/libr;
 }
 }
 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



Re: [PHP] why doesn't this work ?

2004-04-18 Thread Robert Cummings
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 lia href=\$file\font color=\#CC\$file/
  
   font/a/libr;
  }
  }
  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.  |
`'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] why doesn't this work ?

2004-04-18 Thread Marek Kilimajer
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.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Array Sorting Headaches

2004-04-18 Thread Torsten Roehr
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] why doesn't this work ?

2004-04-18 Thread Daniel Clark
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 lia href=\$file\font color=\#CC\$file/

font/a/libr;
   }
   }
   closedir($handle);
}

echo /ul;
?

the output page contains :

$file
; } } closedir($handle); } echo 
; ?

I don't understand why.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] why doesn't this work ?

2004-04-18 Thread Daniel Clark
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?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] session var problems

2004-04-18 Thread Kathleen Ballard
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] why doesn't this work ?

2004-04-18 Thread Dave G
 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]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] addslashes vs. mysql_real_escape_string

2004-04-18 Thread John W. Holmes
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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] session var problems

2004-04-18 Thread Daniel Clark
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] example from meloni not working

2004-04-18 Thread Anthony Ritter
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
h1You 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



AW: [PHP] example from meloni not working

2004-04-18 Thread Red Wingate
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
h1You 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



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] example from meloni not working

2004-04-18 Thread Richard Harb
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
 h1You 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



Re: [PHP] example from meloni not working

2004-04-18 Thread Anthony Ritter
Thank you.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] example from meloni not working

2004-04-18 Thread Anthony Ritter
Thank you.
TR

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Regexp hyperlink

2004-04-18 Thread Martin Visser
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=_blankhotmail/a a 
href=http://www.hotmail.com; target=_blankhotmail/a a 
href=http://www.hotmail.com; target=_blankwww.hotmail.com/a a 
href=http://www.hotmail.com; target=_blankhttp://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=_blankhttp://www.hotmail.com/a]hotmail[/link] [link=a 
href=http://www.hotmail.com; target=_blankwww.hotmail.com/a 
target=_blankhotmail/a a href=http://www.hotmail.com; 
target=_blankwww.hotmail.com/a a href=http://www.hotmail.com; 
target=_blankhttp://www.hotmail.com/a

the last two (without the [link=] part) are working

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Regexp hyperlink

2004-04-18 Thread Richard Harb
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=_blankhotmail/a a 
 href=http://www.hotmail.com; target=_blankhotmail/a a 
 href=http://www.hotmail.com; target=_blankwww.hotmail.com/a a
 href=http://www.hotmail.com;
 target=_blankhttp://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=_blankhttp://www.hotmail.com/a]hotmail[/link] [link=a 
 href=http://www.hotmail.com; target=_blankwww.hotmail.com/a 
target=_blankhotmail/a a href=http://www.hotmail.com; 
target=_blankwww.hotmail.com/a a href=http://www.hotmail.com; 
target=_blankhttp://www.hotmail.com/a

 the last two (without the [link=] part) are working

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] session var puzzle

2004-04-18 Thread Kathleen Ballard
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



Re: [PHP] session var puzzle

2004-04-18 Thread Richard Harb
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] test, please ignore

2004-04-18 Thread Michal Migurski


-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



php-general Digest 18 Apr 2004 23:57:03 -0000 Issue 2713

2004-04-18 Thread php-general-digest-help

php-general Digest 18 Apr 2004 23:57:03 - 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]


--
---BeginMessage---
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---
---BeginMessage---
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---
---BeginMessage---
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---
---BeginMessage---
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---
---BeginMessage---
Burhan Khalid 

Re: [PHP] session var puzzle

2004-04-18 Thread Tom Rogers
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Problems compiling a DSO in BSD/OS 5.1

2004-04-18 Thread The Doctor
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] session var puzzle

2004-04-18 Thread Larry Brown
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] why doesn't this work ?

2004-04-18 Thread Andy Ladouceur
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 lia href=\$file\font color=\#CC\$file/
font/a/libr;
  }
  }
  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