Can't access .php files that aren't .index.php [FIXED]

[UPDATE] The problem has been resolved. It was an issue with my code, not with permissions.

I wrote a .php file for a global leaderboard for my game. However, GetAsync returns nil when I try to access it from Studio and it shows the following when I try accessing it from my browser. However, index.php loads up fine. Is this a permission issue and how can I fix it?

image

2 Likes

Status code 500 means that there is an error in your php. Sharing your code would make it a lot easier to trouble shoot this issue. Make sure you didn’t forget any ‘;’ at the end of a line and if you’re passing any params via the URL bar make sure that they’re defined.

Also youre using HttpService GetAsync correct?

Had to send it as an image because the formatting was getting messed up.

2 Likes

I would be careful using a txt file for storing data like that. I used to do it but after around ~1k entries it would get corrupt. Also it looks like it looks like your passing data via headers, you should use normal data for that.

But for the solution do echo json_encode($leaderboardData); – Nvm I might be wrong

Also you’re using “===” in the if statement. That compares if the type of the values are the same, you should change it to only “==”

If you would like help setting up a Database, please message me.

2 Likes

Can you put this at the top of your PHP file, if Kullaske’s solution doesn’t work.

ini_set('display_errors', 1);

Also, I suggest following Kullaske’s advice, I’d highly recommend using a database.

REQUEST_METHOD is a string, so using triple equal is valid.

2 Likes

Edit: NVM ignore this post
Yes but if the request method was also “GET” that if statement would pass. I think that is what causing the error because it can’t find the data used on other lines.

No, it wouldn’t. Triple equal compares both the value and type. If both are true, it’ll pass.
That also wouldn’t throw a 500 error. 500 errors can throw in php if error output is disabled. (the ini_set code enables error outputting)

1 Like

Whoops you’re right. I thought the identical operator only checked the type.

1 Like

The .txt file will hold 80 entries at most so I think it should be fine.

@fireboltofdeath let me try adding that rn

1 Like

Nothing happened when I added that line.

1 Like

You put it under a PHP tag, right?

<?php
ini_set('display_errors', 1);
?>
1 Like

Editing the data will still corrupt it at some point. But if your heart is set on using the file, I would use .json instead of .txt

1 Like

It wasn’t inside before but I moved it inside and still nothing happened.

I’ll change it to .JSON <3

1 Like

Are you using 00webhost?

I’m using hostinger which I think is part of 000webhost?

Mhm, they’re owned by the same company.

To enable errors on it go to the .htaccess file make sure it is “php_value display_errors 1”

Then see if there are any errors now

Where can I find the .htacess file?

It should be here https://lt-files.hostinger.com/

image

Not there :frowning:

1 Like