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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jgille07
Forum Newbie
Posts: 4
Joined: Thu Jan 13, 2011 6:07 pm

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

Post 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.
Peter Kelly
Forum Contributor
Posts: 143
Joined: Fri Jan 14, 2011 5:33 pm
Location: England
Contact:

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

Post 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.
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

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

Post 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.
klevis miho
Forum Contributor
Posts: 413
Joined: Wed Oct 29, 2008 2:59 pm
Location: Albania
Contact:

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

Post by klevis miho »

My guess is that it is an option in PHP, how PHP interprets the code.
Post Reply