Recently I followed a tutorial for making a forum with PHP and MySQL. Then I got this error:
Error: parsererror - SyntaxError: Unexpected token < in JSON at position 0
I figured out why it was saying that. There was a error on save.php and which was caused due to a error in conn.php this is the full error on conn.php :
Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in /home/runner/AnchoredHeftyTrigger/conn.php:6 Stack trace: #0 /home/runner/AnchoredHeftyTrigger/conn.php(6): PDO->__construct('mysql:host=loca...', 'root', '') #1 {main} thrown in /home/runner/AnchoredHeftyTrigger/conn.php on line 6
This is the code of conn.php:
<?php
session_start();
$db_username = 'root';
$db_password = '';
$conn = new PDO('mysql:host=localhost;dbname=forum',
$db_username, $db_password);
if(!$conn){
die("Fatal Error: Connection Failed!");
}
?>
I'm sorry if I'm not giving much information: I'm very new with PHP and JSON