Page 1 of 2

I am stumped! php does not echo on localhost

PostPosted: 03. June 2014 06:12
by OrcaSoul
I just installed the latest version of XAMPP on Win 7 64bit, have made no changes beyond the security recomended changes.

The XAMPP Control Panel is working with both Apache and MySQL running.

From https://community.apachefriends.org/f/viewtopic.php?f=16&t=68213&p=234390&hilit=echo+working#p234390, I copied the code:
Code: Select all
<?php
echo "This is a test for php.";
?>


and it runs as it should:
This is a test for php.


I copied a bit more complicated code from the w3schools.com site http://www.w3schools.com/php/php_forms.asp:
The html file welcome.html:
Code: Select all
<html>
<body>

<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>

</body>
</html>


And the php file welcome.php:
Code: Select all
<html>
<body>

Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>

</body>
</html>

On the site test area this gives:

Welcome Alice B. Tokis
Your email address is: abt@gmail.com


When I copied these files directly to my htdocs and run it I get:

Welcome
Your email address is:


The php echo statements simply do not work!

This was the reason for installing the XAMPP update, I assumed something in the current install had been damaged somehow.

That apparently was not the case...

If I had written this code I would assume it had an error, but their code works on the web site, but not in the localhost...

This has got me totally stumped - anyone have any ideas?

Re: I am stumped! php does not echo on localhost

PostPosted: 03. June 2014 06:38
by JJ_Tagy
The code works fine. Not sure why it doesn't work for you. Check your error logs (php and apache).

OrcaSoul wrote:The php echo statements simply do not work!

Obviously php echo works on your machine as you posted in the first half.

Re: I am stumped! php does not echo on localhost

PostPosted: 03. June 2014 08:27
by OrcaSoul
A check of xampp/php/logs/php_error_log shows:
[03-Jun-2014 05:47:17 Europe/Berlin] PHP Warning: file_get_contents(lang.tmp): failed to open stream: No such file or directory in C:\xampp\htdocs\xampp\index.php on line 2


There is a lang.tmp in xampp/security/htdocs & xampp/htdocs/xampp - where else should there be one?
I did a search for earlier versions of XAMPP, they all have a lang.tmp in the same two locations.
And all are 2 bits in size...

And what's with the German time stamp on the error?

EDIT:
Oh, and the C:\xampp\htdocs\xampp\index.php file has:
Code: Select all
<?php
   if(file_get_contents("lang.tmp")=="")
   {
      header("Location: splash.php");   
      exit();
   }
?>
<html>
<head>
<meta name="author" content="Kai Oswald Seidler">
<meta http-equiv="cache-control" content="no-cache">
<?php include("lang/".file_get_contents("lang.tmp").".php"); ?>
<title>XAMPP <?php include('.version');?></title>

<frameset rows="74,*" marginwidth="0" marginheight="0" frameborder="0" border="0" borderwidth="0">
    <frame name="head" src="head.php" scrolling=no>
<frameset cols="150,*" marginwidth="0" marginheight="0" frameborder="0" border="0" borderwidth="0">
    <frame name="navi" src="navi.php" scrolling=no>
    <frame name="content" src="start.php" marginwidth=20>
</frameset>
</frameset>
</head>
<body bgcolor=#ffffff>
</body>
</html>

Re: I am stumped! php does not echo on localhost

PostPosted: 03. June 2014 08:35
by Altrea
Please don't jump from one topic to another.
This message is unrelated to your issue.

OrcaSoul wrote:When I copied these files directly to my htdocs and run it I get:

HOW do you run WHICH file? Step by step please

My guess: You open the file the wrong way.

Re: I am stumped! php does not echo on localhost

PostPosted: 03. June 2014 10:34
by Nobbie
Altrea wrote:My guess: You open the file the wrong way.


+1

Re: I am stumped! php does not echo on localhost

PostPosted: 03. June 2014 18:22
by OrcaSoul
Altrea wrote:Please don't jump from one topic to another.
This message is unrelated to your issue.


Hmmm...I'm not sure what you are trying to say...my issue is that when I run an html form I do not get the result I should, which is for the php file it posts to, get the posted data displayed on the screen by the echo function...
Which, I believe, is the question I asked in the original post.
Now, in a prior thread I had confused the database files with the php/html file - but that was cleared up and I now know better...this is not related to that issue.

So...what issue is unrelated to what I posted?

Altrea wrote:
OrcaSoul wrote:When I copied these files directly to my htdocs and run it I get:

HOW do you run WHICH file? Step by step please

My guess: You open the file the wrong way.


I apologize, I assumed that an expert in XAMPP would know that, when I describe two files - one an html form and the other a php post - would understand that the html form was the one that would be opened in the browser...by clicking on it in Windows Explorer...

OK, here is the step by step.
1: I copied the Welcome.html file into the C:/xampp/htdocs folder.
2: I copied the Welcome.php file into the C:/xampp/htdocs folder.
3: I clicked on the C:/xampp/htdocs/Welcome.html file, which opened up in Firefox (that's the browser I use) and presented me with a form:
Name:
E-mail:
Submit

I entered the name into the name box, and the email into the email box - and clicked Submit, which is the button that posts the form to the Welcome.php file, which is supposed to echo the name and email to the screen.
There is where the problem seems to occur - it did not do so.

So please, Sir Moderator, what would be the correct way to open the html?

Re: I am stumped! php does not echo on localhost

PostPosted: 03. June 2014 19:08
by JJ_Tagy
OrcaSoul wrote:So...what issue is unrelated to what I posted?

He is referring to your second post referring to the lang.tmp which has absolutely nothing to do with your original post.

OrcaSoul wrote:...by clicking on it in Windows Explorer...

... and that's your problem.

OrcaSoul wrote:So please, Sir Moderator, what would be the correct way to open the html?

Through your browser as a request to your server - not through windows which doesn't care about the server to process php. http://localhost/ is your server. So http://localhost/welcome.html would be the correct way to request the page from the server. Also, it will be case sensitive so Welcome.html is not the same as welcome.html.

BTW, being an ass is no way to get help.

Re: I am stumped! php does not echo on localhost

PostPosted: 03. June 2014 20:23
by OrcaSoul
JJ_Tagy wrote:
OrcaSoul wrote:So...what issue is unrelated to what I posted?

He is referring to your second post referring to the lang.tmp which has absolutely nothing to do with your original post.

I was responding to YOUR post in which you suggested I "Check your error logs (php and apache)."...and I did find an error message in xampp/php/logs/php_error_log:
[03-Jun-2014 05:47:17 Europe/Berlin] PHP Warning: file_get_contents(lang.tmp): failed to open stream: No such file or directory in C:\xampp\htdocs\xampp\index.php on line 2

Seriously...how is that not related to my original issue - or your request?
YOU suggested I look in the log file, I did and reported what I saw. If that error message isn't relative to my issue, and to your request, what should I look at next?

JJ_Tagy wrote:
OrcaSoul wrote:...by clicking on it in Windows Explorer...
... and that's your problem.

Actually, I use Firefox...but if you mean I should enter "http://localhost/welcome.html" (and I tried both the link you gave AND typing it in directly), that worked - thank you for that.

JJ_Tagy wrote:
OrcaSoul wrote:So please, Sir Moderator, what would be the correct way to open the html?

Through your browser as a request to your server - not through windows which doesn't care about the server to process php. http://localhost/ is your server. So http://localhost/welcome.html would be the correct way to request the page from the server. Also, it will be case sensitive so Welcome.html is not the same as welcome.html.

BTW, being an ass is no way to get help.

How is asking a valid question - and expecting at least a reasonable response, if not a solution - being an"ass"?
When I posted my original question, I stated "When I copied these files directly to my htdocs and run it I get:" - simply asking me how I "ran it" was somewhat less than informative...why not ask if I clicked on the file (the usual way to run most files in Windows) or entered it in the browser? That at least would have given me some alternative to try.
In the prior thread on my confusion about database belonging in htdocs, why didn't someone simply state that the htdocs folder is for html & php, and the mysql/data folder is where the actual database files go? That would have made a lot more sense than having to be even more confused by the replies I was getting - my stating that the DB went into htdocs should have told anyone who actually understands the way it works that I was confusing the two kinds of file.
OK, the point I am trying to make is that
1: I really am not very knowledgeable in databases or how XAMPP is structured. I had managed to create a database in an earlier version, and assumed that what worked then would work in the upgrade. But it did not. The shortcuts I had used - successfully - in prior versions did not work in the current one, and the problem seemed to be in the way the php was not functioning. Not being aware that the old ways no longer worked, I assumed there was a problem in how the code was working. I understand that now, but some actual assistance instead of vague hints would have bee appreciated.
2: I have found this to be a problem with a number of "help forums", replies are short, often with little context to the novice who needs the help, and often with assumptions that I understand the system related word, and that it even applies to my system. I have received solutions that are related to UNIX, even after I state at the start I an running Windows.
Offering assistance has to rely on both parties speaking the same language, at the same level. And giving an answer that is obviously beyond the knowledge of the recipient does not help.
Anyway, rant over - hopefully you see the point I am trying to make.
Thanks for your help.

Re: I am stumped! php does not echo on localhost

PostPosted: 03. June 2014 21:07
by Altrea
OrcaSoul wrote:Seriously...how is that not related to my original issue - or your request?
YOU suggested I look in the log file, I did and reported what I saw. If that error message isn't relative to my issue, and to your request, what should I look at next?

Not every message you find must be related to your issue and you was not able to identify that on your own so i don't wanted that you invest too much time to that. Thats all. The message you have find is normal behaviour for XAMPP installations if the orange xampp administration page was accessed the very first time, so everything is fine with that message.

OrcaSoul wrote:why not ask if I clicked on the file (the usual way to run most files in Windows) or entered it in the browser? That at least would have given me some alternative to try.

Because we are trying to provide help to help yourself. Everybody learns most out of issues by identifying issues ourself as far as we can.
There are various ways to "open a file" and if the lesson will be to describe more precise to get faster help, that will be an important lesson too.

OrcaSoul wrote:In the prior thread on my confusion about database belonging in htdocs, why didn't someone simply state that the htdocs folder is for html & php, and the mysql/data folder is where the actual database files go?

That exactly was what the helpers was trying to talk to you, but you was trying to disagree to that.
We can not watch inside your head what you are knowing and thinking.

OrcaSoul wrote:That would have made a lot more sense than having to be even more confused by the replies I was getting - my stating that the DB went into htdocs should have told anyone who actually understands the way it works that I was confusing the two kinds of file.

Nobody here was guessing that you use the word "database" wrong for sql files. How should we guess that you don't know and use this or that word correctly?

OrcaSoul wrote:1: I really am not very knowledgeable in databases or how XAMPP is structured. I had managed to create a database in an earlier version, and assumed that what worked then would work in the upgrade. But it did not. The shortcuts I had used - successfully - in prior versions did not work in the current one, and the problem seemed to be in the way the php was not functioning. Not being aware that the old ways no longer worked, I assumed there was a problem in how the code was working. I understand that now, but some actual assistance instead of vague hints would have bee appreciated.

That way (double clicking a html file that referenced to a php file) was NEVER working! Your local browser can't have any clue that there is a local webserver running on your system you want to request files through.

OrcaSoul wrote:2: I have found this to be a problem with a number of "help forums", replies are short, often with little context to the novice who needs the help, and often with assumptions that I understand the system related word, and that it even applies to my system. I have received solutions that are related to UNIX, even after I state at the start I an running Windows.
Offering assistance has to rely on both parties speaking the same language, at the same level. And giving an answer that is obviously beyond the knowledge of the recipient does not help.

Maybe if you are trying to be a helper yourself in one of the support boards will give you the insight that it is not that easy than you think now.

Re: I am stumped! php does not echo on localhost

PostPosted: 03. June 2014 21:24
by Nobbie
OrcaSoul wrote:I stated "When I copied these files directly to my htdocs and run it I get:" - simply asking me how I "ran it" was somewhat less than informative...why not ask if I clicked on the file (the usual way to run most files in Windows) or entered it in the browser?


Why did you only state "i run it" instead of " i entered the URL ..... into my browser", or "double clicked that file in my explorer". YOU have to learn, how to describe your actions as PRECISELY as possible.

OrcaSoul wrote:That at least would have given me some alternative to try.
In the prior thread on my confusion about database belonging in htdocs, why didn't someone simply state that the htdocs folder is for html & php, and the mysql/data folder is where the actual database files go?


Because we simply did not have the clue and actually not the slightest idea, what you are going to do and why. Only (and not one second before) as you quoted the advice from Apache, to put all your "data" into htdocs - that was the point, were i got the clue, where you are going wrong.

OrcaSoul wrote:That would have made a lot more sense than having to be even more confused by the replies I was getting


This is your point of view. From my point of view (and you have no idea, how difficult it is, to understand the questions from other people), i had no idea what you are aiming at. We NEVER had such a problem before (you are definately the very first, how mixes up DocumentRoot of Apache and Data Directory of MySQL).

You have NO IDEA, how extremely difficult it is to understand the problems, as we have NO sight on your monitor, we cannot see your harddisk, we dont know anything. We have to follow your (poor) explanations. This is more than extremely difficult (but, anyway, we finally found it out! You could see EVERYTHING - and you did not solve anything).

Try to understand problems from others users and try to give proper answers - you will see, that this BY FAR more difficult than only to maintain your own installationt. And you still cannot maintain your own installation - you are still doing lots of severe errors, like "clicking HTML files in explorer". Did you ever for any Server click HTML files in your explorer? Or do you start your browser and enter an appropriate URL?

OrcaSoul wrote:And giving an answer that is obviously beyond the knowledge of the recipient does not help.


Would you please give us some links to your own answers to any technical issues? I want to see, if you really ever helped somebody and how you did it. And how your kind of answers are better then ours.

Re: I am stumped! php does not echo on localhost

PostPosted: 05. June 2014 06:39
by OrcaSoul
Sorry for the delay, there was a death in the family.

OK, I'm going to fore-go writing a book here, and just state that we obviously have different ways of looking at a "help" forum that handles questions from a wide range of users, most of whom are not looking for a degree in computer science, just some guidance around a problem they can't find an answer to.
And I understand that you answer the same questions many times.

But look at it from my POV - I am working to get ready for a weekend craft/art show at the end of the month, I have about 20 pieces I need to make (I am a wood-turner and make bowls and tea lights and candlesticks and such), I have 180+ done but need to enter them in the database catalog, and cross reference them with the wood table so I can track what wood I have used. I also need to record the time-sheets to be able to compute my costs and set a price. And then the database breaks. So I've lost a week banging my head against the keyboard trying to find out why and how to fix it.

I don't have time to have someone hand me a loaf of bread and a bottle of water and say "Here, Grasshopper, go out and seek.". I simply needed to have some clues as to what I was doing wrong. And, like a lot of people who come asking for help, I know a little about this, but am already frustrated because I wasn't able to work it out myself. And comes along a teacher who say's "that's not the way to do it", and walks off without a suggestion to help. If I got a bit testy, I apologize, but I hope you can see why your approach didn't help.

I will try to be more precise in my requests, but that will inherently be limited by the fact that I am not sure what I need to ask - and if I did know, probably wouldn't be asking in the first place! It's sorta like if you asked me how to use a jam chuck, and I simply said "On a lathe.". You probably would not really get much help from that...

I have nothing against exploring the unknown - I do it all the time - but there are times when that is a workable method, and times when it is not. And I suspect that most of the people who seek help from the experts like you guys are like me, a bit on the frantic side, just trying to get the thing working again, and do the exploring when there is time for that.

And, as to my experience instructing people, I have done that on the web when I was helping people work with some Python scripts I wrote for 3D artists - most people complimented me on the detail I was able to understand from their questions and respond in a useful way. That project is no longer active for other reasons, but I was able to solve a high percentage of the problems simply by listening to what their questions said without saying it.
I also instructed the engineers in the office I worked at before retiring on the many utility programs I wrote to meet their needs.

Look, you guys are the experts, you know the system. Most people who ask for help are not, they simply need someone to point out what they are missing, and offer some alternatives.

I finally got XAMPP to work by ignoring all the obtuse solutions offered on the web, and plotting the problem out on paper.

I do appreciate what you did teach me - both about the database system, and how to approach problems I may need to seek help on in the future.

Re: I am stumped! php does not echo on localhost

PostPosted: 05. June 2014 11:38
by JJ_Tagy
I think a major part of the problem was your approach. You started off stating that (and I'm paraphrasing from both threads) XAMPP has problems and it is not the way it works, [this is] the proper procedure, and not providing much more than that. Which we can only assume that you think you know what you are doing but we tried to tell you that you were incorrect. From that point, you took a defensive stance which clouded your ability to calmly and completely explain your issues and ask for help (or in some cases see the answer/response and not just a "loaf of bread and bottle of water").

Re: I am stumped! php does not echo on localhost

PostPosted: 05. June 2014 15:20
by Nobbie
OrcaSoul wrote:But look at it from my POV - I am working to get ready for a weekend craft/art show at the end of the month, I have about 20 pieces I need to make (I am a wood-turner and make bowls and tea lights and candlesticks and such), I have 180+ done but need to enter them in the database catalog, and cross reference them with the wood table so I can track what wood I have used.


It is quite clear what you mean, but as many others, you overlooked a very important thing:

I am what you call an "expert" for computer programs etc. - that is right. That took me many, many years, And not only a few days. But i am definately not a wood-turner and honestly, if would like to have a nice bowl or so, I never(!) would try to build it on my own. I am absolutely sure, that i would badly fail. I never had an education for that. Same for a plasma TV (only for example), I definately cannot build a plasma TV, this is by far to sophisticated.

I would go the easy way: I would buy these things. Because I am not an expert for bulding would bowls or plasma TVs.

On the other hand, installing, configuring, maintaining an running a webserver is also a very sophisticated task, which needs well educated people to manage all the problems that may arise. Why the hell do you (or many others) believe, that you can do that on your own, with no education, no experience, no skills, only a few computer things, but honestly far from what it needs for all these things. Why are you going this horrible way, instead of asking someone, to do this for you and (of course) offer some money for that? This is quite the same as if you try to build your own plasma TV. You cannot do everything on yourself. This is, what i dont understand. Why do people know, that they cannot build their own TVs, or their cars, but they believe, that they can substitute a well educated computer administrator? You cannot solve all these problems only in a few days. That is impossible. Anyway, you try. Why??

Re: I am stumped! php does not echo on localhost

PostPosted: 05. June 2014 19:06
by OrcaSoul
JJ_Tagy wrote:I think a major part of the problem was your approach. You started off stating that (and I'm paraphrasing from both threads) XAMPP has problems and it is not the way it works, [this is] the proper procedure, and not providing much more than that. Which we can only assume that you think you know what you are doing but we tried to tell you that you were incorrect.


Oh, you told me I was wrong - correctly - but you neglected to tell me what I should be doing instead. You were right to tell me that htdocs was not used for the database, but how hard would it had been to say what it IS used for?

JJ_Tagy wrote:From that point, you took a defensive stance which clouded your ability to calmly and completely explain your issues and ask for help (or in some cases see the answer/response and not just a "loaf of bread and bottle of water").


Yes, I was wrong in my insistence that I was right, but it's hard to "calmly and completely explain your issues" when you are confused and not that aware of how the system works. YOU are the people who DO know, and it's up to you to try to get more information from the person you are helping? YOU know where most people get confused and need help, and you need to draw on that to help the search for that proper answer. WE do not have that background, if we did we probably would not ask for help.

I get it that you don't understand that, so let's leave it there...

Re: I am stumped! php does not echo on localhost

PostPosted: 05. June 2014 19:33
by OrcaSoul
Nobbie wrote:
OrcaSoul wrote:But look at it from my POV - I am working to get ready for a weekend craft/art show at the end of the month, I have about 20 pieces I need to make (I am a wood-turner and make bowls and tea lights and candlesticks and such), I have 180+ done but need to enter them in the database catalog, and cross reference them with the wood table so I can track what wood I have used.


It is quite clear what you mean, but as many others, you overlooked a very important thing:

I am what you call an "expert" for computer programs etc. - that is right. That took me many, many years, And not only a few days. But i am definately not a wood-turner and honestly, if would like to have a nice bowl or so, I never(!) would try to build it on my own. I am absolutely sure, that i would badly fail.


"Absolutely sure"...so you won't even try?

But then, what of all the people who DO try to learn enough of XAMPP? Should they say "I can't do this, so why ask?"? No, they give it a try, find some problems with their understanding, and seek aid from those who should be able to help...

Shouldn't they be able to expect that those helping do more than criticize, perhaps try to understand why these folks are having a problem? We don't expect you to write our code, but we do want at least a clue as to not only where we are wrong, but how we should look at the problem in order to solve it.

Nobbie wrote:I never had an education for that. Same for a plasma TV (only for example), I definately cannot build a plasma TV, this is by far to sophisticated.

I would go the easy way: I would buy these things. Because I am not an expert for bulding would bowls or plasma TVs.


Neither was I six years ago, now I have made over 700 of them. I call it my "Meditation", because when I am turning everything else goes somewhere else, I have to concentrate on the work, I become one with the wood - letting the wood tell me what it wants to be.

My only problem is figuring out how best to sell them...but I've been stumbling around working on that for years, seeking and GETTING advice from those who are successful, and think I am getting close - like many things, it just takes practice, error, and friendly help to find the right mix.

You cheat yourself when you decide ahead of time you can't do it.

Nobbie wrote:On the other hand, installing, configuring, maintaining an running a webserver is also a very sophisticated task, which needs well educated people to manage all the problems that may arise. Why the hell do you (or many others) believe, that you can do that on your own, with no education, no experience, no skills, only a few computer things, but honestly far from what it needs for all these things. Why are you going this horrible way, instead of asking someone, to do this for you and (of course) offer some money for that? This is quite the same as if you try to build your own plasma TV. You cannot do everything on yourself. This is, what i dont understand. Why do people know, that they cannot build their own TVs, or their cars, but they believe, that they can substitute a well educated computer administrator? You cannot solve all these problems only in a few days. That is impossible. Anyway, you try. Why??


Interesting - here you are offering to help people do something you don''t think they should be doing...why are you working on a forum for a software system you don't think the rabble should be using?

That may explain a lot as to why we are having this conversation...

And I have work to do, so thanks for your help...