8 thoughts on “05 – SQL search for keywords

  1. I've followed everything step by step and I get this error message: "Notice: Trying to get property of non-object in" I've checked the line where the error happens and it's written exactly the same as in the video.

  2. I'm getting the following error after adding my second query…

    Parse error: syntax error, unexpected end of file in C:xampphtdocsAmbriaBrownDatabaseProject.php on line 61

    <title>Database Systems</title>

    <html>

    <head>

    </head>

    <body>

    <h1>VIP MEMBERS</h1>

    <?php

    $host = "localhost";

    $username = "root";

    $user_pass = "";

    $database_in_use = "databaseproject";

    $mysqli = new mysqli("$host", "$username", "$user_pass", "$database_in_use");

    if ($mysqli->connect_errno) {

    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;

    }

    echo $mysqli->host_info . "<br>";

    $sql = "SELECT Member_ID, First_Name, Last_Name, City, State FROM vipmembers";

    $result = $mysqli->query($sql);

    if ($result->num_rows > 0) {

    // output data of each row

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

    echo "id: " . $row["Member_ID"]. " – First_Name: " . $row["First_Name"]. " " . $row["Last_Name"]. " " . $row["City"]. " " . $row["State"]. "<br>";

    }

    } else {

    echo "0 results";

    }

    //Search Member who live in Atlanta

    echo "<h2>Show all members who live in Atlanta </h2>";

    $sql = "SELECT Member_ID, First_Name, Last_Name, City, State FROM vipmembers WHERE City LIKE '%Atlanta%'";

    $result = $mysqli->query($sql);

    if ($result->num_rows > 0) {

    // output data of each row

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

    echo "id: " . $row["Member_ID"]. " – First_Name: " . $row["First_Name"]. " " . $row["Last_Name"]. "<br>";

    }

    } else {

    echo "0 results";

    $mysqli->close();

    ?>

    </body>

    </html>

  3. Hi Shad Thank you I've spent weeks trying to understand this. I last worked on databases 40 years ago. By taking every single step and where to find the information was wonderful. Please can you make your screen a little bit bigger as I sometime could not see where I was to check for mistakes. Fabulous tutorial going through all of them slowly….. Very slowly regards J

Leave a Reply

Your email address will not be published. Required fields are marked *