nzorb Posted June 1, 2011 Share Posted June 1, 2011 Ok first of all I want to apologize for asking what I'm about to ask. I understand it should be some stupidly easy to find mistake but considering the fact I have to send the code tomorrow leaves me with little to no time to try and find the solution so I'll be asking here and hope that by the time I wake up tomorrow an answer will be here and I'll be able to resume scripting. So my problem is that I just can't find how to make php commands run at all. I tried just randomly inserting them into my html code then found out it needs a separate file. So I created the basic.php with this code: <html> <body> <?php echo "Hello World"; ?> <div>adgaeganerhaohn</div> </body> </html> tried opening it through a form in my html code but it wouldn't print the Hello world line, then I tried running it straight into firefox but I only got adgaeganerhaohn again (without that line I get a white page) So I need to know what am I doing wrong? I have php5.301 installed with default options (no server). thanks for your help beforehand, once I get a bit more into php I'll be coming back with serious questions but for now I really need someone to tell me how php is supposed to work and what I'm doing wrong Quote Link to comment https://forums.phpfreaks.com/topic/238055-totaly-basic-problemfirst-time-using-php/ Share on other sites More sharing options...
fugix Posted June 1, 2011 Share Posted June 1, 2011 you will need to have a server to run php script since it communicates with the server...you can use a localhost to do this which is free Quote Link to comment https://forums.phpfreaks.com/topic/238055-totaly-basic-problemfirst-time-using-php/#findComment-1223308 Share on other sites More sharing options...
Psycho Posted June 1, 2011 Share Posted June 1, 2011 You HAVE to have a webserver installed. If you try to open a file with PHP code in it directly in your web browser it has no clue how to parse PHP code. So, it just triesd to renders it all as HTML. You have to request the page from a web server. THe server then sees you want a PHP page. It takes the page and processes it then sends the result (HTML code) to your browser. Once you have a webserver installed (check out XAMPP) you can put the php files into the htdocs folder on your PC. Then you could access them via http://localhost/filename.php Quote Link to comment https://forums.phpfreaks.com/topic/238055-totaly-basic-problemfirst-time-using-php/#findComment-1223309 Share on other sites More sharing options...
fugix Posted June 1, 2011 Share Posted June 1, 2011 yes you can simply google xampp or localhost server to find many sites that direct you on how to set it up.. Quote Link to comment https://forums.phpfreaks.com/topic/238055-totaly-basic-problemfirst-time-using-php/#findComment-1223310 Share on other sites More sharing options...
Psycho Posted June 1, 2011 Share Posted June 1, 2011 ...you can use a localhost to do this which is free Your use of terminology will cause confusion. A "localhost" is not a webserver. Every machine has a "localhost" it is simply an internal domain name pointing the machine back to itself. When you use localhost in the URL you are simply making an http (usually) request back to the pc itself. It is no different than using the machines name or IP address. For example you can ping a cmputer back to itself using localhost even if it has no web server installed. And, you can have a webserver (which uses localhost) which is not free. Quote Link to comment https://forums.phpfreaks.com/topic/238055-totaly-basic-problemfirst-time-using-php/#findComment-1223311 Share on other sites More sharing options...
nzorb Posted June 1, 2011 Author Share Posted June 1, 2011 wow tnx for the fast replies all! So all I have to do is set up a server with php support and throw the files there (even if 'there' is just my pc), sounds like a stupidly hard way to run a simple site but I guess there's a logical explanation behind it that I'll understand at some point tnx again I think this thread should be considered solved! Quote Link to comment https://forums.phpfreaks.com/topic/238055-totaly-basic-problemfirst-time-using-php/#findComment-1223313 Share on other sites More sharing options...
fugix Posted June 1, 2011 Share Posted June 1, 2011 ...you can use a localhost to do this which is free Your use of terminology will cause confusion. A "localhost" is not a webserver. Every machine has a "localhost" it is simply an internal domain name pointing the machine back to itself. When you use localhost in the URL you are simply making an http (usually) request back to the pc itself. It is no different than using the machines name or IP address. For example you can ping a cmputer back to itself using localhost even if it has no web server installed. And, you can have a webserver (which uses localhost) which is not free. yes sorry if my wording caused confusion...thanks for clearing that up mjd Quote Link to comment https://forums.phpfreaks.com/topic/238055-totaly-basic-problemfirst-time-using-php/#findComment-1223460 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.