Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2019
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP error after placing code

    Hi.. I am just learning mysql and php. I thought I had mysqli and pdo issues fixed but did something stupid I think. Trying to learn php connecting with mysql, I used this code:

    PHP Code:
    <?php
    $servername 
    "localhost";
    $username "zzzz";
    $password "zzzz";
    $dbname "zzzzz";

    // Create connection
    $conn = new mysqli($servername$username$password,$dbname);

    if (
    $conn->connect_error)
    {
    die(
    "Connection failed: " $conn->connect_error);
    }
    // sql to delete a record
    $sql "DELETE FROM golfers WHERE lname = 'Adams'";

    if (
    $conn->query($sql) === TRUE) {
    header("Location: index.php");
    } else {
    echo 
    "Error deleting record: " $conn->error;
    }

    $conn->close();
    mysqli and pdo worked fine before running this code in localhost.

    copied and pasted in haste and didn't notice this line: header("Location: index.php"); It seems like this line changed something in configuration or something???

    Immediately after doing this the localhost/php_del.php url did not work at all. So I rebooted the computer. After rebooting the computer I found that none of my scripts that connect php to mysql work at all. I get this message now: Fatal error: Uncaught Error: Class 'mysqli' not found in C:\Apache24\htdocs\php_del.php:8 Stack trace: #0 {main} thrown in C:\Apache24\htdocs\php_del.php on line 8. I believe I have screwed up some index or caused a redirection problem.

    I have no idea how to fix this. Can anyone help?

    Incidentally, the name was deleted from the table successfully. Before everything went sour.

    Thanks much!
    Last edited by vinyl-junkie; Jan 17th, 2019 at 02:43 PM. Reason: added code tags

  2. #2
    Master Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    5,803
    Thanks
    26
    Thanked 602 Times in 595 Posts
    Fatal error: Uncaught Error: Class 'mysqli' not found
    This message has nothing to do with your database. It tells you that the mysqli extension of your PHP installation is either disabled or not installed (note: mysqli is not enabled by default). See PHP: phpinfo - Manual to get the current configuration of your PHP installation.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •