-2

1 - Here's a image of my error code .. The purple color zone is the zone commented out automatically and I don't know why it happens...

enter image description here

2 - I use Mozilla Firefox and Chrome, and bothwhere happens this. 3 - I use XAMPP to connect 80 Apache and 3306 to MySQL ... db works good

...WHY MY CODE GETS COMMENTED OUT? SOME HELP? I can give more info if needed thx

user3287450
  • 31
  • 1
  • 4
  • 1
    PHP isn't HTML. When you try to parse PHP as HTML the browser performs error recovery. It converts a lot of PHP syntax to comments. – Quentin Jan 19 '16 at 14:37
  • because you can't view `php` files the same way you do with `html`. you need a XAMPP/WAMP, whatever apache+php server – Alex Tartan Jan 19 '16 at 14:37
  • 1
    "I use XAMPP to connect 80 Apache and 3306 to MySQL" — No you don't, your screenshot shows that you are using `file:///` instead of `http://` (item 6 on the accepted answer of the duplicate question) – Quentin Jan 19 '16 at 14:38

2 Answers2

1

Because you're loading it from a file url. Your browser is loading that file's contents directly, there's no webserver involved, which means your browser is interpreting your PHP code as invalid HTML tags.

You can NOT run php like this. You need a webserver, and access that script via a full-blown http://.... url.

Marc B
  • 356,200
  • 43
  • 426
  • 500
0

You are surfing to the file instead of your XAMPP server. You have to surf to localhost:80 to make it work.

Don't forget to put all of your files in the root folder of the XAMPP server too.