Pegasus3245 Posted September 29, 2012 Share Posted September 29, 2012 Hi All, Having a dilema here... I run a games server, its a crap web based game - ill not go into detail. Anyhow, the server URL changes when the server is restarted, this is automatically saved into a text file. I then have a batch file which automatically copies this file onto my web server every 10 minutes. I then have a php page which reads this text file and a couple others. The webpage looks a little like; Server Status online Server Address www.webgame.com etc.etc.... The problem is, the link doesnt display as a clickable link, this is what I am wanting. Its just displayed as plain text, you have to then copy and paste this link into your browser, I would really like the link to just be clickabe. The code I am currently using is; <p align="center" class="style1">Server Location:</p> <p align="center" class="style3"> <?php $filename = "externalurl.txt"; $filehandle = fopen($filename, "r"); $contents = fread($filehandle, filesize($filename)); fclose($filehandle); echo $contents; ?> </p> <br> I basically want the link to display as is, I did try putting the whole thing inside <a href"<CODE>"> this unsurprisingly didnt work. I have seen loads of other help websites etc, these all only show methods of displaying links that have the actual code in the text file, my text file has no code in there, just the actual link - and this cannot be changed. Any help would be greatly apreciated. Quote Link to comment https://forums.phpfreaks.com/topic/268909-text-file-links/ Share on other sites More sharing options...
berridgeab Posted September 29, 2012 Share Posted September 29, 2012 When you echo $contents, what is the actual output? Quote Link to comment https://forums.phpfreaks.com/topic/268909-text-file-links/#findComment-1381749 Share on other sites More sharing options...
Pegasus3245 Posted September 29, 2012 Author Share Posted September 29, 2012 Hi Berridgeab, Thanks for your reply. All the text file has inside is http://www.gameserverlocation.com just the 1 line. The output is just that, which i have working, but i want it to be a clickable link, rather than just a link you have to copy and paste. Quote Link to comment https://forums.phpfreaks.com/topic/268909-text-file-links/#findComment-1381764 Share on other sites More sharing options...
ignace Posted September 29, 2012 Share Posted September 29, 2012 <p align="center" class="style1">Server Location:</p> <p align="center" class="style3"> <a href="<?= file_get_contents('externalurl.txt') ?>">click here</a> </p> <br> Quote Link to comment https://forums.phpfreaks.com/topic/268909-text-file-links/#findComment-1381771 Share on other sites More sharing options...
Pegasus3245 Posted September 30, 2012 Author Share Posted September 30, 2012 (edited) Hi Ignace, Thats great, its working as a link now, however I have the issue that the hyperlink has my web server address in front followed by a , even though the text file doesnt have this inside. Text File: www.gameserver.com <p align="center" class="style1">Server Location:</p><p align="center" class="style3"><a href="<?= file_get_contents('externalurl.txt') ?>">click here</a></p><br> This produces click here to have a link to: www.myserver.com/http://www.gameserver.com cant figure this one out. Kind Regards, Scott. Edited September 30, 2012 by Pegasus3245 Quote Link to comment https://forums.phpfreaks.com/topic/268909-text-file-links/#findComment-1381870 Share on other sites More sharing options...
Christian F. Posted September 30, 2012 Share Posted September 30, 2012 That's called the "Byte Order Mark". A search for it and the name of the editor you're using should help you figure out how to get rid of it. Quote Link to comment https://forums.phpfreaks.com/topic/268909-text-file-links/#findComment-1381886 Share on other sites More sharing options...
Pegasus3245 Posted September 30, 2012 Author Share Posted September 30, 2012 I managed to get arround it using; <?php $section = file_get_contents('tempurl.txt', NULL, NULL, 3, 100); ?>[/b] [b]<?php echo "$section";?> Quote Link to comment https://forums.phpfreaks.com/topic/268909-text-file-links/#findComment-1381892 Share on other sites More sharing options...
Christian F. Posted September 30, 2012 Share Posted September 30, 2012 That's a hack, which will break if the BOM ever is removed. I recommend fixing it properly. Quote Link to comment https://forums.phpfreaks.com/topic/268909-text-file-links/#findComment-1381894 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.