marcus Posted December 18, 2006 Share Posted December 18, 2006 Parse error: syntax error, unexpected T_STRING in /home/csblog/public_html/file.php on line 8What I am trying to do, is to get file contents of a website and echo them off, but if a link exists i want it to also direct it to the same page[code]<?php$url = $_GET['url'];if(!isset($url)){echo "<form method=get><input type=text name=url value=http://><input type=submit value=Go></form>";}else {$file = file_get_contents("$url");echo "<form method=get><input type=text name=url value=http://><input type=submit value=Go></form><br><br>";$replace = "href='."http://cs-blog.net/file.php?url=$url".'";$file = str_replace('href="',$replace,$file);echo $file;}?>[/code] Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 18, 2006 Share Posted December 18, 2006 well what r u trying to do with line 8 like the href[CODE]<?php$url = $_GET['url'];if(!isset($url)){echo "<form method=get><input type=text name=url value=http://><input type=submit value=Go></form>";}else {$file = file_get_contents("$url");echo "<form method=get><input type=text name=url value=http://><input type=submit value=Go></form><br><br>";$replace = "href=' . "http://cs-blog.net/file.php?url=$url" . '";$file = str_replace('href="',$replace,$file);echo $file;}?>[/CODE] Quote Link to comment Share on other sites More sharing options...
marcus Posted December 18, 2006 Author Share Posted December 18, 2006 that doesnt work either Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 18, 2006 Share Posted December 18, 2006 yes im asking u what ur trying to do wiht line 8 Quote Link to comment Share on other sites More sharing options...
drifter Posted December 18, 2006 Share Posted December 18, 2006 mgallforever - your quotes are all messed up on that line and we can not tell what you want to do.. something needs to be escaped? more quotes added. not really sure. Quote Link to comment Share on other sites More sharing options...
marcus Posted December 18, 2006 Author Share Posted December 18, 2006 Oh, so basically it replaces the text that has href= in it, to change it to href="http://cs-blog.net/file.php?url=$url""but if i add the double quote around $url then it tries to end it Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 18, 2006 Share Posted December 18, 2006 Line 8, which is:[code]<?php$replace = "href=' . "http://cs-blog.net/file.php?url=$url" . '";?>[/code]Is wrong WRT the quotes. Try:[code]<?php$replace = "href='http://cs-blog.net/file.php?url=$url'";?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted December 18, 2006 Share Posted December 18, 2006 here lol why dont u do this'href="http://cs-blog.net/file.php?url=$url"'; Quote Link to comment Share on other sites More sharing options...
marcus Posted December 18, 2006 Author Share Posted December 18, 2006 say, the url you typed in was like miniclip.com or something. the links there are just href="/games/gamename.php"i want so when the person clicks that it will go to ?url=http://miniclip.com/games/gamename.phpthat didnt work ken, when i went to my other site, chyea.net and tried to click contact it stayed on chyea.net not chyea.net/contact.php Quote Link to comment Share on other sites More sharing options...
marcus Posted December 18, 2006 Author Share Posted December 18, 2006 Chris, that would just output $url, literally. Quote Link to comment Share on other sites More sharing options...
drifter Posted December 18, 2006 Share Posted December 18, 2006 [code] $domain="mydomain.com"; $myscript="something.php"; $thisurl="http://" . $domain . $script . "?url="; $regex = "/<\s*a\s+[^>]*href\s*=\s*[\"']?([^\"' >]+)[\"' >]/isU"; preg_match_all($regex,$page,$urls); $urlarray=array_unique($urls[1]); foreach($urlarray AS $url){ //echo $url . " " . $newurl . "<br>"; if($url!='#' && $url!='/'){ $newurl=$thisurl . urlencode($url); if(!strstr($url,'http://')){ $page=str_replace($url,$newurl,$page); } } }[/code]Is this what you want?take all the URLs and put them on a query string? Quote Link to comment Share on other sites More sharing options...
marcus Posted December 18, 2006 Author Share Posted December 18, 2006 Um, that wouldnt work, the url is given as a get, and i'm trying to make it produce it so that links with href=" will be produced in href="http://cs-blog.net/file.php?url=$url" and if it was from chyea.net the index would just stay at chyea.net then if you clicked contact it would be href="http://cs-blog.net/file.php?url=http://chyea.net versus href="http://cs-blog.net/file.php?url=http://chyea.net/contact.php"But on the page it comes out with: http://cs-blog.net/file.php?url= but in the source it shows http://cs-blog.net/file.php?url=$url"contact.php"[code]<?php$url = $_GET['url'];if(!isset($url)){echo "<form method=get><input type=text name=url value=http://><input type=submit value=Go></form>";}else {$file = file_get_contents("$url");echo "<form method=get><input type=text name=url value=http://><input type=submit value=Go></form><br><br>";$replace = 'href="http://cs-blog.net/file.php?url=$url"';$file = str_replace('href="',$replace,$file);$file = str_replace('../',"",$file);echo $file;}?>[/code] Quote Link to comment Share on other sites More sharing options...
trq Posted December 18, 2006 Share Posted December 18, 2006 For the third time. Variables are not parsed within single quotes.[code=php:0]$replace = "href='http://cs-blog.net/file.php?url=$url'";[/code] Quote Link to comment Share on other sites More sharing options...
marcus Posted December 18, 2006 Author Share Posted December 18, 2006 href='http://cs-blog.net/file.php?url=http://chyea.net'/forums.php"I get that Quote Link to comment Share on other sites More sharing options...
trq Posted December 18, 2006 Share Posted December 18, 2006 Please, take the time to read the link in my signiture. It will benifit us all in the future. 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.