Page 1 of 1

PHP is automatically adding quotes and won't allow '<'

Posted: Sun Jan 30, 2011 2:41 am
by jgille07
I have a site up and running just fine with plenty of functions that echo html form elements and work successfully, but today I added a couple more functions to a class and on one of the feedback pages after a user adds an entry to the database I was trying to echo variables the same exact way i have on other pages (which are still working) and variables in an array that were names of SQL column fields were being returned as 0's.
I also noticed that php started automatically adding quotes around anything i echoed.
So if i had a line: echo "Hello World"; it would output "Hello World" (displaying the quotes as if it were part of the string).

I created an entirely new php page with only the following code on it:

Code: Select all

<?php
     echo "<form></form";
?>
and it keeps on giving me the following error:
Parse error: syntax error, unexpected '>' in filename on line ##

Does anybody have any idea what could be causing this to happen?
I would greatly appreciate any suggestions on where to start to look to figure this out.

Re: PHP is automatically adding quotes and won't allow '<'

Posted: Sun Jan 30, 2011 6:24 am
by Peter Kelly

Code: Select all

<?php
     echo "<form></form>";
?>
for starters you was missing > on the </form and just paste that directly into a blank .php file and paste here exactly what it comes out with.

Re: PHP is automatically adding quotes and won't allow '<'

Posted: Mon Jan 31, 2011 1:52 am
by cpetercarter
PHP doesn't know the rules of html syntax and prints out bad html without difficulty if you ask it to. (In my scripts, it often has to! :D ). So I doubt that the missing '>' is the problem. (Incidentally, your code will not output anything to a browser screen - the browser will interpret it as html - albeit malformed. You would need to look at the page source to see the output).

My guess is that you are not running the script that you have posted as a freestanding bit of code (ie you are not calling, say, http://www.mysite.com/test.php), but that you are running it in through the code which runs your site. I think you need to tell us a bit more about that. If the problems started when you added some new functions to a class, then it is almost certainly those functions which are the problem - php does not by itself behave in the erratic fashion you have described.

Re: PHP is automatically adding quotes and won't allow '<'

Posted: Mon Jan 31, 2011 4:30 am
by klevis miho
My guess is that it is an option in PHP, how PHP interprets the code.