dre38w Posted December 22, 2011 Share Posted December 22, 2011 echo will not print out a value. I do the simple string " " and it doesn't even do that. It's just blank in my browser. I use netbeans and firefox and chrome. Any idea as to what I'm doing wrong? Simple code snippet: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>PHP Testing</title> </head> <body> <?php echo "print me"; ?> </body> </html> Thanks for any future help. Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/ Share on other sites More sharing options...
kicken Posted December 22, 2011 Share Posted December 22, 2011 Most likely cause: You do not have PHP installed and running properly. Open the page in your browser and view-source. If you can see your <?php ?> tags and the code between them, then your PHP is not setup properly and your pages are not being executed. Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1300612 Share on other sites More sharing options...
xProteuSx Posted December 22, 2011 Share Posted December 22, 2011 Is your file a .php file? Or are you using PHP in a HTML file? Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1300614 Share on other sites More sharing options...
AGuyWithAthing Posted December 22, 2011 Share Posted December 22, 2011 Do you have a web server that supports PHP? as the <?php ?> will just been seen as a XML entity and not render any of the contents in the browser. Look at the source of the page and if the PHP is still embedded then your web server doesn't support PHP. Also, are you just trying to open the .php file in a browser if so this also won't work as the PHP files need to go through the PHP Binary to be compiled on the fly. Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1300616 Share on other sites More sharing options...
Mavent Posted December 22, 2011 Share Posted December 22, 2011 I suppose I should have clarified: Everything else on the Site is in .php. Everything else works fine. This is exactly the contents of the file, which is named test.php <?php echo "<a href='test.php?v4=".$v4."> Places</a>"; echo "<a href='test.php?v4=$v4'>Places</a>"; echo "<a href='test.php?v4=Utah'>Places</a>"; ?> Thanks! Kyle Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1300619 Share on other sites More sharing options...
dre38w Posted December 22, 2011 Author Share Posted December 22, 2011 @kicken: Well that seems to be the issue. haha It is exactly how my code is in netbeans. Solution? @xProteuSx: Yes it's a .php file. Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1300622 Share on other sites More sharing options...
melloorr Posted December 22, 2011 Share Posted December 22, 2011 I suppose I should have clarified: Everything else on the Site is in .php. Everything else works fine. This is exactly the contents of the file, which is named test.php <?php echo "<a href='test.php?v4=".$v4."> Places</a>"; echo "<a href='test.php?v4=$v4'>Places</a>"; echo "<a href='test.php?v4=Utah'>Places</a>"; ?> Thanks! Kyle What cant you display them either? With double quotes, you do not need any ' around your link: echo "<a href=test.php?v4=Utah>Places</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1300624 Share on other sites More sharing options...
dre38w Posted December 22, 2011 Author Share Posted December 22, 2011 Wow. Thank you for all these fast replies! AGuyWithAthing: I'm not sure if it supports it or not. How would I find this out? And I tried both from the actual file and through pushing the run button. Mavent: Sorry, I'm not sure what you mean. Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1300629 Share on other sites More sharing options...
melloorr Posted December 22, 2011 Share Posted December 22, 2011 Wow. Thank you for all these fast replies! AGuyWithAthing: I'm not sure if it supports it or not. How would I find this out? And I tried both from the actual file and through pushing the run button. Mavent: Sorry, I'm not sure what you mean. Are you using a host service like godaddy or something. Or are you using a localhost, i.e, YOU installed php on your computer. If you using neither, then you will not see any php. Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1300630 Share on other sites More sharing options...
dre38w Posted December 22, 2011 Author Share Posted December 22, 2011 melloorr: I'm using localhost yes. A host service no. Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1300631 Share on other sites More sharing options...
melloorr Posted December 22, 2011 Share Posted December 22, 2011 melloorr: I'm using localhost yes. A host service no. Well, I am assuming you are accessing your website through localhost/yoursebsite/index.php or just localhost/index.php ? Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1300632 Share on other sites More sharing options...
dre38w Posted December 22, 2011 Author Share Posted December 22, 2011 localhost/yoursebsite/index.php Yes like that. Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1300634 Share on other sites More sharing options...
melloorr Posted December 22, 2011 Share Posted December 22, 2011 Then the only possible reason is that it didn't install properly. Did you install in manually, or did you use a program like xampp? If you did install yourself, uninstall and try using xampp or a similar program. Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1300638 Share on other sites More sharing options...
dre38w Posted December 22, 2011 Author Share Posted December 22, 2011 Okay, let's try using xampp then. Thank you. I'll let you know what happens after I reinstall it using that. Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1300640 Share on other sites More sharing options...
AGuyWithAthing Posted December 22, 2011 Share Posted December 22, 2011 Usually a quick way to test if it's working is to put a php info file in the root of your webserver. If you're using xampp for windows the dir is usually C:\Program Files\xammp\htdocs or something along those lines ain't used XAMPP in years. Make a file like phpinfo.php (be sure that the extension is PHP enable show file extensions in your folder settings) and in that file add the following: <?php phpinfo(); Then go to http://localhost/phpinfo.php and see if you get a page similar to : http://www.n3tw0rk.co.uk/info.php Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1300644 Share on other sites More sharing options...
dre38w Posted December 24, 2011 Author Share Posted December 24, 2011 I installed xampp and had to put my projects in the htdocs folder and change a few settings and it worked. A co-worker helped with the final touches of this problem but I thank you all for your helpful and quick replies. Back to work for me!! haha Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/253709-echo-not-working/#findComment-1301194 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.