I decided to write a forum using PDO
.
I do not understand what the problem is, it gives an error 500.
In a separate file, everything works fine, in the main file there.
- File function.class.php:
I decided to write a forum using PDO
.
I do not understand what the problem is, it gives an error 500.
In a separate file, everything works fine, in the main file there.
It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:
In the getForums()
function that is represented in the image, the $pdo
variable is not declared. Apparently this is an object for working with the database, which is declared in the global scope. But in php
in the body of the function global variables are not available until they are explicitly declared:
$wow='wow'; //глобальная переменая function sayWow(){ global $wow; //теперь переменная доступна в теле функции echo $wow; }
In your case, most likely, getForums()
is a method of some class. So use $this
:
public function getForums(){ /* ... */ $this->pdo->query('SELECT * FROM forums'); /* ... */ }
And don't forget to inject $pdo
in a constructor or a separate method.
Source: https://ru.stackoverflow.com/questions/507598/
All Articles
umbrella_forum
") as $ row) - DimaRRR