Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
can't parse a variable
Old 09-01-2008, 01:44 PM can't parse a variable
Skilled Talker

Posts: 77
Name: Bill Benson
Location: Florida
Trades: 0
I've worked for hours on this. Any help is appreciated.

I've got something line this. I'm inputting variables in a form. selecting a template from a db table, then writing a web page.

for simplicity say the template is: <html>$var</html>

Page:

$template='test';
$page='test';
$var='marcia';

$query11="SELECT template_text FROM `page_template` WHERE template = '$template'";
$result11=mysql_query($query11) or die ("couldn't execute query11");
$num11=mysql_numrows($result11);
$template_text=mysql_result($result11,$i11,"templa te_text");
$depage="$template_text";

$page="/subdirectory/$page.php";

$myfile = fopen ("/home/name/public_html/$page","w");
fwrite ($myfile, "$depage\n");
fclose ($myfile);

The page is written but it is:

<html>$var</html>

-----------------------------------------------------------------

Now if I do this it works:

$page='test';
$var='marcia';
$depage="<html>$var</html>";
$page="/subdirectory/$page.php";

$myfile = fopen ("/home/name/public_html/$page","w");
fwrite ($myfile, "$depage\n");
fclose ($myfile);

This writes the following page test.php which is what I want:

</html>marcia</html>

-----------------------------------------------------------

How do I get example 1 to work using the template with the variable in it?
bill benson is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-01-2008, 03:05 PM Re: can't parse a variable
Sleeping Troll's Avatar
Ultra Talker

Posts: 351
Name: Butch Begy
Trades: 0
echo "<html>".$var."</html>";

Last edited by Sleeping Troll; 09-01-2008 at 03:08 PM..
Sleeping Troll is offline
Reply With Quote
View Public Profile
 
Old 09-01-2008, 05:40 PM Re: can't parse a variable
Skilled Talker

Posts: 77
Name: Bill Benson
Location: Florida
Trades: 0
echo where?

The variable $depage contains <html>$var</html>. I tried '<html>'.$var.'</html>' in the template, but it didn't work. I didn't try it with double quotes though.

I'm trying to write a html page though, not display it. Where would an echo help me write the page?

Effictively I'm doing this:

filling our a form and posting them as variables
grabbing a template from a db that contains text and $var (and other variables)
saving the variables in a db (this works. all variables are being posted)
writing a webpage from the template. This works

the script at the point I am trying to write contains:
The script also contains $variable1='x';
$template which is text$VARIABLE1text

All of this works if I place the template in a variable on the page ie $template="text$variableText";

If I select the exact same content from a table and put it in a variable named $template it doesn't work.
bill benson is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to can't parse a variable
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25279 seconds with 12 queries