FutureQuest, Inc. FutureQuest, Inc. FutureQuest, Inc.

FutureQuest, Inc.
Go Back   FutureQuest Community > General Site Owner Support (All may read/respond) > PHP, Perl, Python and/or MySQL
User Name
Password  Lost PW

Reply
 
Thread Tools Search this Thread Display Modes
Old 04-07-1999, 04:54 PM   Postid: 42442
Justin
Visitor
 
Justin's Avatar

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: Jan 1999
Location: Kissimmee, FL
Posts: 3,672
Are you wanting the script to remember variables between runs? Like, run the script, script is finished, run again, and it remembers? I'm afraid that wouldn't work (that would be static variables, BTW).

The reason is that the script is in fact dead once it's done it's thing Even an ordinary Windows program - the only way it can remember from a previous session is to save settings in the Registry or an INI file - not in a variable. While there is no registry and writing to a file would be too much work, hidden form fields are the way to go here

Example:

$header = "<html><head>
<title>My Dynamic Page</title>
</head>
<body>";

Later...

print "<form action=script.php3 method=post>
<input type=hidden name=tophtml value=\"$header\">
.....";

However, that is a lot of extra html to be downloaded and re-uploaded - there should be a much easier way to do what you are wanting to do. I don't know what it is you are trying to do, but there will be an easier way than storing html snippets in a form field or variable...

---

Ok, just scrolled down and took a closer look. Here's what you should do:

$fruit = "rutabaga";
...
print "<input type=hidden name=fruit value=$fruit>";

Then assemble it later in the script, instead of doing the work over and over - just hold the info a little at a time until it's all gathered and then put it all together


------------------
Justin Nelson
FutureQuest Support





[This message has been edited by Justin (edited 04-07-99).]
Justin is offline   Reply With Quote
Old 04-07-1999, 05:31 PM   Postid: 42443
SneakyDave
Fond of TAZ
 
SneakyDave's Avatar

Forum Notability:
93 pts: Helpful Contributor
[Post Feedback]
 
Join Date: Feb 1999
Posts: 919
Hey Justin, I think that'll work. I don't know why I thought the static fields were still "available" after the script was reloaded, all I can blame it on was that it was late.

I was trying to use the hidden form field, but I couldn't get it to work right, I think this way will work better anyway.

[disclaimer]
By the way, in no way was I trying to infer that rutabagas are my favorite fruit, nor that they are the root of my PHP ignorance.
[/disclaimer]

Thanks again.
Sneaky
SneakyDave is offline   Reply With Quote
Old 04-07-1999, 08:35 PM   Postid: 42444
SneakyDave
Fond of TAZ
 
SneakyDave's Avatar

Forum Notability:
93 pts: Helpful Contributor
[Post Feedback]
 
Join Date: Feb 1999
Posts: 919
Hey Justin, I can't get it to work right. The hidden variable only stores about 6 characters of my text that I want to reference.

Can I email you offline (again!) with what I'm trying to do?

Thanks for your time

Sneaky
SneakyDave is offline   Reply With Quote
Old 04-07-1999, 08:53 PM   Postid: 42445
SneakyDave
Fond of TAZ
 
SneakyDave's Avatar

Forum Notability:
93 pts: Helpful Contributor
[Post Feedback]
 
Join Date: Feb 1999
Posts: 919
Hold the phone, I got it to work another way.....

For whatever reason, the hidden form variable didn't like more than 8 characters even with a MAXLENGTH and SIZE parameter on it, but I got around it.

Justin, thanks for your input, it inspired me to try something else, and I think its going to work.

I'd like to get the hidden form variable to work as expected though, so if you have the time, send me your phone number, and I'll discuss the problem with you. Its HIGHLY CLASSIFIED information, dealing with bacon and its effect on the John Hancock building in Chicago.

Thanks again..
Sneaky
SneakyDave is offline   Reply With Quote
Old 04-07-1999, 11:30 PM   Postid: 42446
Justin
Visitor
 
Justin's Avatar

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: Jan 1999
Location: Kissimmee, FL
Posts: 3,672
If there is whitespace in the hidden field, you have to quote it. However, I NEVER use double quotes in HTML - just single one's (like that appostrophie I just used there hehe). You don't have to escape them for some reason in PHP.

In fact, PHP is far more forgiving that Perl with that stuff - the only thing I have found that needs escaping is " and that's about it

But anyway, you'd need to do this:

print "<input type=hidden name=food value='$food'>";

Then when that form is submitted, it passes the variable $food with the same value it just had

I love php to death, and combine that with MySQL - well, then you have my next site (also classified - deals with other pork products (mainly pork rhinds) and a trailer park near the Gateway Arch).

BTW - I already know about bacon's effects on the Hancock center - the grease has a 'slick' effect on the slanted top causing bird droppings to slide down, land on cars and cause accidents and traffic jams on Lake Shore Drive. I saw the white paper on codename "PidgeonJam" myself, and we are taking it quite seriously (I live near Chicago )

Wow, I'm in a silly mood tonight, huh? Feel free to email me about the php if you want. On a side note I absolutely cannot call a perl script from php either - only works locally
Justin is offline   Reply With Quote
Old 04-08-1999, 12:06 AM   Postid: 42441
SneakyDave
Fond of TAZ
 
SneakyDave's Avatar

Forum Notability:
93 pts: Helpful Contributor
[Post Feedback]
 
Join Date: Feb 1999
Posts: 919
Global variable problem in PHP?

The subject may be incorrect, but this is the problem I'm having....

I have a PHP script that build somes HTML and puts it in a variable, such as this:

$fruit .= "<HTML><BODY>";
$fruit .= "My favorite is the rutabaga";
$fruit .= "</BODY></HTML>";
print $fruit;

And then there is a form where a user may fill out some additional information, and press a submit button that reloads the PHP script with a different parameter.

The problem I have is that after the script is reloaded, the $fruit variable is null, I can't use it after the script reloads, although I don't initialize it anywhere in the code.

Now, I may be being stupid assuming the variable would not be reinitialized, but I thought that was the case with PHP. I even tried assigning the $fruit variable to a hidden variable in a form ($FormFruit), and THEN trying to reference it after the script is reloaded, but that didn't work either.

Do I need to either somehow assign the $fruit variable as a global variable (which probably isn't the correct term), or do I have to make sure that the $fruit variable is passed in a form under an "assumed" name, just so that I can reference it somewhere else in my script?

Any help will be appreciated. Thanks
Sneaky

(I edited this to remove the "code" ubb code because of a bug in which the "/code" command doesn't work).

[This message has been edited by SneakyDave (edited 04-07-99).]
SneakyDave is offline   Reply With Quote
Old 04-08-1999, 11:46 AM   Postid: 42447
SneakyDave
Fond of TAZ
 
SneakyDave's Avatar

Forum Notability:
93 pts: Helpful Contributor
[Post Feedback]
 
Join Date: Feb 1999
Posts: 919
Hey, I think that '$food' idea might work. It was doing some crazy things the other way with the double quotes, as in "value="$food">";, it assumed the ">"; at the end of that line was part of the VALUE...
Anyway, even with the struggle, I'll have it done faster than doing it in Perl.

And on the other note, I've given up on the Perl script call from PHP. I'm just going to try to do it all in PHP using a flat file. I'm not a big tech support specialist on FQ to afford MySQL, although using it would be a blast I'm sure.

I'm off to do some reconnaisance(sp?) on the effects of pigs feet being thrown on the WalMart MegaCenter down the street. Wish me luck.

Sneaky
SneakyDave is offline   Reply With Quote
Old 04-09-1999, 10:43 AM   Postid: 42448
SneakyDave
Fond of TAZ
 
SneakyDave's Avatar

Forum Notability:
93 pts: Helpful Contributor
[Post Feedback]
 
Join Date: Feb 1999
Posts: 919
Justin, just a note to say that the ' worked a lot smoother than the ". I wish I would have known that before, it makes the whole script a lot easier to read in a lot of cases.

SneakyDave is offline   Reply With Quote
Old 04-09-1999, 11:22 AM   Postid: 42449
Justin
Visitor
 
Justin's Avatar

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: Jan 1999
Location: Kissimmee, FL
Posts: 3,672
Just a quick note: be careful not to include a ' in the variable itself...

$fruit = "Don't Care";

The resulting HTML would be:

<input type=hidden name=fruit value='Don't Care'>

See the problem? Just be careful, or even strip them out of the value before putting them in the form...

------------------
Justin Nelson
FutureQuest Support



Justin is offline   Reply With Quote
Old 04-09-1999, 03:53 PM   Postid: 42451
kk
Visitor

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: Apr 1999
Location: Bangkok
Posts: 4
Hi,

Try AddSlashes() - it'll quote ', ", \ with
backslash (mean \', \", \\ in order).

and do StripSlashes() for reverse operation.

Somehow, if you don't want to quote or want to quote only some characters. Try str_replace() instead.

PS: urlencode()/ urldecode() can also do similar thing.

Yours,
-kk-
Thai-IMEX.com
(Yes! It's powered by FutureQuest & PHP & MySQL)
kk is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 11:11 PM.


Running on vBulletin®
Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.
Hosted & Administrated by FutureQuest, Inc.
Images & content copyright © 1998-2013 FutureQuest, Inc.
FutureQuest, Inc.