Can you help me here ! I get this wrong in my PHP code when I open it in localhost. Fatal error : Uncaught mysqli_sql_exception: A connection attempt failed because the connected party did not...


Can you help me here !


I get this wrong in my PHP code when I open it in localhost.






Fatal error: Uncaught mysqli_sql_exception: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond in C:\xampp\htdocs\labb4\moment3.php:18 Stack trace: #0 C:\xampp\htdocs\labb4\moment3.php(18): mysqli->__construct('studentmysql.mi...', 'arkh2000', 'qc18cg6j', 'arkh2000') #1 {main} thrown inC:\xampp\htdocs\labb4\moment3.php on line18



The code is :












    $page_title
"; ?>











    $db =  new mysqli(DBHOST, DBUSER, DBPASS, DBDATABASE);
    //$db =  new mysqli(DBHOST, DBUSER, DBPASS, DBDATABASE);
        if($db->connect_errno > 0) {
        die("Fel vid anslutning: " . $db->connect_error);
    }


    if(isset($_POST['user'])) {
        $user = $_POST['user'];
        $content = $_POST['content'];


        // Lägg till data
        $sql = "INSERT INTO guestbook(user, content)VALUES('$user', '$content')";
        $result = $db->query($sql);
    }


    ?>




Lämna en kommentar

















































    // SQL-fråga


    $sql = "SELECT * from guestbook ORDER BY created DESC";
    $result = $db->query($sql);


    while($row = $result->fetch_assoc()) {
        ?>
















            }
    ?>












Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here