ok tried that and it did nothing.
I would expect to see some php code in my newly created php file.
All i am seeing is what was initially set when the page was created.
ok tried that and it did nothing.
I would expect to see some php code in my newly created php file.
All i am seeing is what was initially set when the page was created.
Sorry to bump.
Anyone?
Sorry to bump again guys but 150+ post's and no one has an answer for me?
how to embed variables into a string:
<?php
$value1="value1 from database";
$value2="value2 from database";
$html='
<html>
...........
$value1 value is: '.$value1.'
<br>
vlue2 is : '.$value2.'
</html>
';
print htmlspecialchars($html);
// then you can save into a new html or php file
?>
Sorry i think we have our wires crossed.
My outputted string/file should have in it
<?php
$pageID= $_GET['pageID'];
?>
save this code as a ..php file, and run it, and watch the output:
<?php
$string='<?php
$pageID= $_GET[\'pageID\'];
?>';
echo htmlspecialchars($string) ;
?>
if you save (fwrite) this string into a file then you can get a working php code which exepts an incoming variable from an URL.
and sorry if i misunderstood something.
Still getting the parse error
Parse error: parse error, expecting
T_STRING' or
T_VARIABLE' or `T_NUM_STRING' in C:\Inetpub\vhosts[/QUOTE]
djjjozsi;10920552 wrote:if you save (fwrite) this string into a file then you can get a working php code which exepts an incoming variable from an URL.
I'm certain that was meant to be "can't get" instead of "can get".
First off, file access is not thread safe over one page request (assuming multiple users)
Imagine two users, A and B.
A sends a GET request
B sends a GET request
A reads 2 FROM $GET['pageID']
A writes 2 to file
B reads 1 FROM $GET['pageID']
B writes 1 to file
Server shows A the page corresponding to pageID 1
Server shows B the page corresponding to pageID 1
Now, over to the error message:
Parse error: parse error, expecting T_STRING' or
T_VARIABLE' or `T_NUM_STRING' in list_html.php on line 58
Line 58. Yet, your posted code shows only 19 lines of code.
Other than that, as previously suggested, you will have to check if $_GET['whatever'] actually is set:
if (isset(...))
or (isset(...) ? ... : null)
Finally, in your anchor tag's href attribute, you need to use "&" instead of "&". Do use a validator, such as http://validator.w3.org/
did you copy that version where i replaced the ' into \' ?
bocouse i missed the single qoute escape.
did you copy that version where i replaced the ' into \' ?
bocouse i missed the single qoute escape.
Tried that and got the same.
Now, over to the error message:
Parse error: parse error, expectingT_STRING' or
T_VARIABLE' or `T_NUM_STRING' in list_html.php on line 58Line 58. Yet, your posted code shows only 19 lines of code.
am not feeling the love
I posted only where the issue is. No need to post all 320 lines of code.
sorry if i am having a blonde moment.
Let's take a couple of steps back and see if i can make things a bit clearer.
This is all fine and works as supposed to.
What i am trying to do next is to put a $_GET['pageID'] in these pages so that the back button on these newly created pages know what previous page to go to.
Suggested scripts in previous post's check the var during page creation. That's not what i want.
Again really sorry if i am just picking you guys up wrong.
You will see 3 different examples, try it on localhost, and you will see how to build string and write into new files. After the files has generated see them and watch the differences.
<?php
function f($filename , $content)
{
file_put_contents($filename , $content);
}
//1
//lets save a variable name into a file
$string='<?php
// $variable is 1
$variable=1;
echo $variable;
?>';
f("1.php" , $string);
?>
//2 Check if a $_GET variable has set in the generated file
<?php
$string='<?php
if(isset($_GET["variable"]))
{
$back=$_GET["variable"];
}
else
$back="";
?>
<html>.....
<?php
if(!empty($back))
echo "<a href=\"?back=$back\">Back</a>";
?>
....</html>
';
f("2.php" , $string);
?>
//3 Lets save an existing variable into a file as a normal link
<?php
if(empty($_GET["PageID"]))
{
print ("Lets set a value to the PageID in your URL, default value is 1!");
$page=1;
}
else
$page=intval($_GET["PageID"]);
$string='
<?php $page='.$page.'; ?>
<html>
<body>
<a href="?pageid=<?php echo $page ?>">Go Back</a>
</body>
</html>
';
f("3.php" , $string);
?>
Cheers man with a bit of modding your second example helped me.
Paul Ferrie;10920906 wrote:Cheers man with a bit of modding your second example helped me.
Great!