X
X
xxxfdd2021-06-28 13:14:21
PHP
xxxfdd, 2021-06-28 13:14:21

Why does it say there is no access to the server?

Forbidden
You don't have permission to access / on this server.

Here is my server that receives two numbers as input and remembers it in the database, but if the number is 3, then the server shows the last value from the database. On the local host, everything works fine, but when I put it on the host, everything was covered with a copper basin

<?php

try{
    if (isset($_GET['a'])) $string_a = htmlentities($_GET['a']);
    if (isset($_GET['b'])) $string_b = htmlentities($_GET['b']);
    
    $db = new PDO('sqlite:game_PDO.sqlite');


     if($string_b == '3'){
        
     $result_id = $db->query('SELECT id, string_a, string_b FROM groups ORDER BY id DESC LIMIT 1');
    foreach($result_id as $row_id) {

        print $row_id['string_a'];
        print '/';
        print $row_id['string_b'];
    }}


    elseif ($string_b != '3'){
    $db->exec("CREATE TABLE groups(id  INTEGER PRIMARY KEY, string_a Text,string_b Text)");

    $db->exec("INSERT INTO groups(string_a,string_b) VALUES($string_a,$string_b);");
}

}

catch(PDOException $e){
    echo $e->etMessage();
}
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Neverov, 2021-06-28
@TTATPuOT

Your problem is not with PHP, but with the server.
Check your server configuration. You have either Apache or Nginx, most likely the latter.
The server simply does not open /index.php, but tries to open the directory. Which, obviously, you do not have access to due to server settings.
Alternatively, you can forcibly go to /index.php in the browser, it might work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question