php-general Digest 26 Dec 2003 03:59:07 -0000 Issue 2494

Topics (messages 173320 through 173327):

Re: problem sending variables with forms
        173320 by: Mike Brum

How New Is <<<HERE?
        173321 by: stiano.optonline.net
        173323 by: Jeremy Johnstone
        173326 by: Jasper Bryant-Greene

Re: Problem with session variables on Mac
        173322 by: Mike Migurski

Re: programming the onclick() event in an anchor
        173324 by: Larry Brown

Re: programming the onclick() event in an anchor [FIXED]
        173325 by: Peter Walter

Apache 2 and PHP
        173327 by: Radek Zajkowski

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 ---
Some code samples would be really helpful. You also said "an error occurred"
but failed to mention any details about that error. That aside, I'll make a
guess at some possible problems:

1) You're trying at access the wrong super global (e.g. GET when you should
be looking for POST). 
2) You're trying to access the variable directly but do not have
register_globals enabled.
3) You're spelling something wrong (we all do it from time to time).
 
-M

-----Original Message-----
From: Abdullah Teke [mailto:[EMAIL PROTECTED] 
Sent: Thursday, December 25, 2003 8:55 AM
To: [EMAIL PROTECTED]
Subject: [PHP] problem sending variables with forms

  I have a problem that  i cant send variable over a form. Because of that
when i watn to echo the variable next page  an error occured...i use redhat
9.0, apache 2 and php 4.3.4. Please help me....


  Abdullah Teke
  _____________________________ 

  Telephone : +90 555 337 21 89
  Messenger  : [EMAIL PROTECTED] 
  Web            : http://abdullahteke.cjb.net 
  Icq              : 164500674

--- End Message ---
--- Begin Message ---
I'm running PHP version 4.3.0 on a Macintosh PowerBook with OS 10.2.1,
doing some PHP tutorial exercises. And I've run across something I haven't
seen before in the sample code I'm seeing:

   print <<<HERE
   [multiple lines of code]
   HERE;

Now, from what I've read, it seems that the point of "<<<HERE ... HERE;" is
to execute all the code between the two "HEREs".

But when I run this thru my browsers--Netscape 7.02 and IE 5.2--I get the
following error message:

   Parse error: parse error, unexpected $ in [path to file] [line number]

Is this "<<<HERE ... HERE;" new to PHP sometime after version 4.3.0, and
I'm just out of luck unless I upgrade?

Thank you.

Steve Tiano


--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .

--- End Message ---
--- Begin Message ---
AFAIK, it has been in PHP since the beginning of PHP4. I could be wrong,
but I think it was one of the new features added when 4.0 came out. Here
is a little reference material for you on it.

http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

Without seeing a code snippet, I can't tell you what your doing wrong.
Probably something simple, but hopefully the document above will help
you. Another resource which gives a decent guide to HEREDOC's is the
fairly new book "Core PHP Programming Third Edition". It's been a while
since I read it, but if memory serves it has atleast a page or two on
it's usage. I also highly recommend that book anyway to any PHP
programmer, beginner all the way to highly advanced. I thought I knew
almost everything about PHP and even I still learned about a new
function or two from the book. Very worthwhile.

Jeremy

On Thu, 2003-12-25 at 12:44, [EMAIL PROTECTED] wrote:
> I'm running PHP version 4.3.0 on a Macintosh PowerBook with OS 10.2.1,
> doing some PHP tutorial exercises. And I've run across something I haven't
> seen before in the sample code I'm seeing:
> 
>    print <<<HERE
>    [multiple lines of code]
>    HERE;
> 
> Now, from what I've read, it seems that the point of "<<<HERE ... HERE;" is
> to execute all the code between the two "HEREs".
> 
> But when I run this thru my browsers--Netscape 7.02 and IE 5.2--I get the
> following error message:
> 
>    Parse error: parse error, unexpected $ in [path to file] [line number]
> 
> Is this "<<<HERE ... HERE;" new to PHP sometime after version 4.3.0, and
> I'm just out of luck unless I upgrade?
> 
> Thank you.
> 
> Steve Tiano
> 
> 
> --------------------------------------------------------------------
> mail2web - Check your email from the web at
> http://mail2web.com/ .

--- End Message ---
--- Begin Message --- It doesn't execute the code between the <<<HERE ... HERE. It's called heredoc syntax for delimiting strings.

Say you had a really long string, with lots of variables in it that needed parsing, and lots of " and ' signs. Instead of using print "" you can use the heredoc syntax. You start with <<< and an identifier (in this case 'HERE') and then end with that identifier and a semicolon. It's just a way for delimiting strings, so you need to look for what's causing that unexpected $ just as if you were looking at a "" string. I can't help you any more without a code snippet.

-- Jasper

[EMAIL PROTECTED] wrote:
I'm running PHP version 4.3.0 on a Macintosh PowerBook with OS 10.2.1,
doing some PHP tutorial exercises. And I've run across something I haven't
seen before in the sample code I'm seeing:

   print <<<HERE
   [multiple lines of code]
   HERE;

Now, from what I've read, it seems that the point of "<<<HERE ... HERE;" is
to execute all the code between the two "HEREs".

But when I run this thru my browsers--Netscape 7.02 and IE 5.2--I get the
following error message:

Parse error: parse error, unexpected $ in [path to file] [line number]

Is this "<<<HERE ... HERE;" new to PHP sometime after version 4.3.0, and
I'm just out of luck unless I upgrade?

Thank you.

Steve Tiano


-------------------------------------------------------------------- mail2web - Check your email from the web at http://mail2web.com/ .

--- End Message ---
--- Begin Message ---
>               $session_time = $current_time - $_SESSION('timestamp');
>                       echo "session time = $session_time seconds.<br>";
>
>The output to the browser (Safari) is as follows:
>
>inside check IF
>Time = 1072308706.
>
>Fatal error: Call to undefined function: array() in
>/Library/WebServer/Documents/testit/Logsafe_project/user_auth_fns.php
>on line 35
>
>As you can see, the code bombs as soon as it hits the
>$_SESSION('timestamp').

$_SESSION is an array, therefore its elements are indexed like so:
$_SESSION['timestamp'].

-mike.

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

--- End Message ---
--- Begin Message ---
You can place <form> tags around the anchors and use hidden tags and send
via post so the variable is not obvious.  A user reading the source would
see this though...

echo "<form name=\"form1\" action=\"https://this.site.com/somePage.php\";
method=\"post\">\n";
echo "<a onClick=\"this.form.submit();\">SomeLinkText</a>\n";
echo "<input type=\"hidden\" name=\"variable\" value=\"".$value."\">\n";
echo "</form>\n";

I'm not sure off the top of my head if the anchor tag must have any other
description.  You might be able to use onChange instead of onClick to
include selection by using the keyboard, but I'm not sure if the anchor tag
responds to onChange.  You'd have to try it out.

Larry.

-----Original Message-----
From: Evan Nemerson [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 25, 2003 2:59 AM
To: Peter Walter; [EMAIL PROTECTED]
Subject: Re: [PHP] programming the onclick() event in an anchor


On Wednesday 24 December 2003 08:06 pm, Peter Walter wrote:
> I have written a session-enabled php page which displays a table of
> search results. The first column in the table contains anchor links to
> www.mydomain.com/mypage?seqno=xxxx where seqno is a variable I would
> like to pass when the anchor is clicked. However, I do not wish the
> ?seqno=xxxx to display in the url of the browser. After googling a lot,
> it appears that I can use JavaScript to set a session variable in the

I doubt it- otherwise it would be pretty easy to set, say
$_SESSION['logged_in']

> onclick() event, but I have not been able to find an example of how to

But you /can/ use JS to set a cookie, which can be retrieved (and stored in
a
session variable if you want) by PHP.

http://www.webreference.com/js/column8/
http://us4.php.net/manual/en/reserved.variables.php#reserved.variables.cooki
es

> do it. Does anyone have experience doing this? Sample code would be
> greatly appreciated.

http://www.webreference.com/js/column8/functions.html

>
> Peter

--
Evan Nemerson
[EMAIL PROTECTED]
http://coeusgroup.com/en

--
"There is a certain right by which we may deprive a man of life, but none by
which we may deprive him of death."

-Nietzsche

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

--- End Message ---
--- Begin Message --- Evan,

Thank you for responding - as a newbie to PHP, HTML, and JavaScript, the cookie approach is a little too complex for me. However, after googling some more, I came across the following approach which seems to be simple and works well:
(a) enclose the result table within a form, specifying the form name as "results", the "post" method, and "action" as the page url to be loaded when the anchor is clicked.
(b) insert a hidden field ("seqnum") within the form.
(c) In the php code which builds the table, for the anchor link, use the following code: ($seqno is the data to be passed)
print "<a href=\"javascript://\" onclick=\"document.results.seqnum.value=$seqno;document.results.submit();\">";
Result: $HTTP_POST_VARS['seqnum'] will be set to the sequence number.
The only downside to this method seems to be that the "visited" anchors do not change color. Can anyone suggest how to fix that?


Peter

Evan Nemerson wrote:

On Wednesday 24 December 2003 08:06 pm, Peter Walter wrote:


I have written a session-enabled php page which displays a table of
search results. The first column in the table contains anchor links to
www.mydomain.com/mypage?seqno=xxxx where seqno is a variable I would
like to pass when the anchor is clicked. However, I do not wish the
?seqno=xxxx to display in the url of the browser. After googling a lot,
it appears that I can use JavaScript to set a session variable in the



I doubt it- otherwise it would be pretty easy to set, say $_SESSION['logged_in']




onclick() event, but I have not been able to find an example of how to



But you /can/ use JS to set a cookie, which can be retrieved (and stored in a session variable if you want) by PHP.


http://www.webreference.com/js/column8/
http://us4.php.net/manual/en/reserved.variables.php#reserved.variables.cookies



do it. Does anyone have experience doing this? Sample code would be
greatly appreciated.



http://www.webreference.com/js/column8/functions.html




Peter






--- End Message ---
--- Begin Message ---
A few months back the official PHP website still warned againts PHP and
Apache 2. I am wondering about the current status of these two technologies
when used together. I am about to configure a web server and was going to
use Apache 1.3 with PHP4+ as opposed to Apache 2 with PHP4+. What are your
opinions, thoughts and experiences.

Thanks in advance.

R>

--- End Message ---

Reply via email to