BlackKite Posted March 31, 2006 Share Posted March 31, 2006 Hello! Ok this is sort of hard to explain but i'll do my best.I've got a php site backend script im developing. A part of the script is a page uploader in which you give the file a title, the page a name, type in the content of the page, and then select from a drop down option list where on the sites navigation column you want the link to be displayed.The problem is that I cant get navigation part to work correctly. I have it setup so that the script opens the index file, searches for a hidden html tag and then replaces the hidden tag with the link and a new hidden tag. In my eyes it looks like the hidden tag isn't being found and the scrip is just passing over that part becuase its not found.Here are the parts of code that are connected to my problem. Any help at all would be appreciated greatly. Thanks!Forms Drop List:[code]Navigation Spot:<br> <select name="navi"><option value="nav1">1</option><option value="nav2">2</option><option value="nav3">3</option></select>[/code] Php script that processes the this part of the form:[code] //Post navigation link on index;$nav = $_POST['navi'];$SData = "<a href=\"index.php?id=$ourFileName\">$ourLinkName</a><br><!-- $nav -->";$data = file_get_contents("$dir/index.php");$data = str_replace ('<!-- $nav -->', $SData, $data);$fp = fopen ("$dir/index.php", 'w');fwrite ($fp, $data);fclose ($fp);[/code]Hidden tags on index.php page:[code]<!-- nav1 --><br><!-- nav2 --><br><!-- nav3 -->[/code] Quote Link to comment Share on other sites More sharing options...
bqallover Posted March 31, 2006 Share Posted March 31, 2006 Hi. Not sure if I follow exactly what you're doing, but it looks to me like you're trying to expand the $nav variable in the str_replace. You'd need to wrap that in double-quotes, not single.Instead of...[code]$data = str_replace ('<!-- $nav -->', $SData, $data);[/code]you'd have...[code]$data = str_replace ("<!-- $nav -->", $SData, $data);[/code]But as I say, I'm not really following the code that well. :) Quote Link to comment Share on other sites More sharing options...
BlackKite Posted March 31, 2006 Author Share Posted March 31, 2006 Wow, im stupid. How did i not think of trying that?!? It worked, lol. Thanks alot! :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.