Jump to content

Whenever I add in PHP code in my HTML file, (using MAMP) I got this HTTP ERROR 500 warning

mrchow19910319
Go to solution Solved by Cruorzy,

Pretty obvious, try to add line by line because it seems you forget to add some ";" there

 

For example after $db variable and $msg variable.

 

Don't write all of it just do line by line and test if you just began

I have set up MAMP on my macbook pro.
However right now if I write any sort of PHP file into the htdocs file, or write any sort of PHP code inside my HTML file, I got this error message:

 

5b7cdcc4b1b63_ScreenShot2018-08-22at11_42_37AM.png.3108a13459b8318f7903339b495fc2ac.png

 

If I remove all of my PHP code, the error message disappear. 

Where did it go wrong?? 

If it is not broken, let's fix till it is. 

Link to comment
Share on other sites

Link to post
Share on other sites

Are you using <?php ?> opening and closing tags, and if not, is it in a <script> and closed?

Link to comment
Share on other sites

Link to post
Share on other sites

it's going to be hard to give an answer without an error log: https://stackoverflow.com/questions/8641383/how-can-i-get-mamp-to-tell-me-what-went-wrong-with-php-code

 

As a general rule, when you run into issues your first step is almost always to find the stack trace to try and get more insight. "error 500" is INCREDIBLY broad, and you need some more info before you know for sure whats wrong. Otherwise you are just taking shots in the dark, which is the debugging equivalent of trying to hit a home run with a blindfold unless you already have some deep intuitions of the code you're working with.

Gaming build:

CPU: i7-7700k (5.0ghz, 1.312v)

GPU(s): Asus Strix 1080ti OC (~2063mhz)

Memory: 32GB (4x8) DDR4 G.Skill TridentZ RGB 3000mhz

Motherboard: Asus Prime z270-AR

PSU: Seasonic Prime Titanium 850W

Cooler: Custom water loop (420mm rad + 360mm rad)

Case: Be quiet! Dark base pro 900 (silver)
Primary storage: Samsung 960 evo m.2 SSD (500gb)

Secondary storage: Samsung 850 evo SSD (250gb)

 

Server build:

OS: Ubuntu server 16.04 LTS (though will probably upgrade to 17.04 for better ryzen support)

CPU: Ryzen R7 1700x

Memory: Ballistix Sport LT 16GB

Motherboard: Asrock B350 m4 pro

PSU: Corsair CX550M

Cooler: Cooler master hyper 212 evo

Storage: 2TB WD Red x1, 128gb OCZ SSD for OS

Case: HAF 932 adv

 

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, Netivity said:

Are you using <?php ?> opening and closing tags, and if not, is it in a <script> and closed?

I am following this video. 

5b7ce1803c519_ScreenShot2018-08-22at12_07_15PM.thumb.png.63e61f1e29da96bcee9d4fdbf0688a07.png

 

If it is not broken, let's fix till it is. 

Link to comment
Share on other sites

Link to post
Share on other sites

8 minutes ago, reniat said:

it's going to be hard to give an answer without an error log: https://stackoverflow.com/questions/8641383/how-can-i-get-mamp-to-tell-me-what-went-wrong-with-php-code

 

As a general rule, when you run into issues your first step is almost always to find the stack trace to try and get more insight. "error 500" is INCREDIBLY broad, and you need some more info before you know for sure whats wrong. Otherwise you are just taking shots in the dark, which is the debugging equivalent of trying to hit a home run with a blindfold unless you already have some deep intuitions of the code you're working with.

i will post more info later. 

If it is not broken, let's fix till it is. 

Link to comment
Share on other sites

Link to post
Share on other sites

4 minutes ago, mrchow19910319 said:

I am following this video. 

-snip-

I can only assume you've already made a connection.php file?

 

EDIT: If not, you have to make a connection.php file that links your database, user and pass, and the database name. I can only see two files open. your .css and your html file

 

Link to comment
Share on other sites

Link to post
Share on other sites

5 minutes ago, Netivity said:

I can only assume you've already made a connection.php file?

 

EDIT: If not, you have to make a connection.php file that links your database, user and pass, and the database name. I can only see two files open. your .css and your html file

 

didnt....

later will try and let you know how it goes. 

danDerp.png.c75de777de2a24da80ea98ead6e7c29b.png

 

If it is not broken, let's fix till it is. 

Link to comment
Share on other sites

Link to post
Share on other sites

37 minutes ago, mrchow19910319 said:

didnt....

later will try and let you know how it goes. 

danDerp.png.c75de777de2a24da80ea98ead6e7c29b.png

 

All good mate,

 

if you get stuck:

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Pretty obvious, try to add line by line because it seems you forget to add some ";" there

 

For example after $db variable and $msg variable.

 

Don't write all of it just do line by line and test if you just began

Quote or mention me if not feel ignored 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×