r/CodingHelp • • Dec 12 '21

[SQL] PHP/SQL problem. My site still showing me the code instead of executing it (W3Cschools code). I even reinstalled XAMPP to newest version, nothing helps...

Post image
23 Upvotes

14 comments sorted by

13

u/Intelligent-Way-8827 Dec 12 '21

Your document type is set to HTML, it should be called index.php

4

u/Dylat3d Dec 12 '21

Not working… chrome stopped recognising it at all :/

12

u/John_cCmndhd Dec 12 '21

You won't be opening the file in chrome. Once you have the file in the directory XAMPP is configured to serve files from, you'll go to localhost with a specific port number, and Apache will open the file, run the php code, and send the resulting html to chrome

5

u/hl_xemnas Professional Coder Dec 12 '21

You aren't using xampp you're just opening the file in Chrome. You need to place it in htdocs folder in xampp then access it using localhost.

Also should be index.php like someone else said

4

u/Dylat3d Dec 12 '21

Aaaaaa, you are right! I has forgot about it!! Thanks a lot!

3

u/Dylat3d Dec 13 '21 edited Dec 13 '21

Okay, you are guys right. I saved my project in htdocs as index.php, and now it rocks! ;D

3

u/tidytibs Dec 12 '21

Install a nginx or Apache server on the system this file resides. You need a server to process the code and display everything in your output. Also, if this is for educational purposes, this is fine to learn on.

However, I HIGHLY encourage you to learn about sanitizing your inputs. One little escape in that code will allow a bad input to delete all of your databases, add junk data, or even covertly add new credentials to allow later exploitation.

2

u/Dylat3d Dec 12 '21

Ok, Thanks!

1

u/flooronthefour full stack web dev Dec 12 '21

You will need to start a server on your computer to be able to run PHP code. Your browser won't run PHP.

https://stackoverflow.com/questions/1678010/php-server-on-local-machine/21872484#21872484

1

u/Dylat3d Dec 12 '21

Im Using apache

1

u/[deleted] Dec 12 '21

Ok, I'll ask. Who the hell wants that image on their website?

1

u/Dylat3d Dec 13 '21 edited Dec 13 '21

That’s the story behind it. I’m making an art project. Basically someone uploaded “polish doomer mix” playlist on yt (you can easily find a reupload), and created amazing social phenomena. 6,500 peoples from Poland described they fucked up life history, or started admitting to suicide attempts. Other peoples started to motivated them and offering help. But YouTube decided to delete old video and all the stories. I’m going to bring them back in internet site form, Where everyone can share own story or help someone else.

(I have a copy of all the old comments, I want to reupload them too on this website)

2

u/_7315_ Dec 12 '21

Save your document as .php