Jump to content

Recommended Posts

I have this script working fine in a dir on my website but now I need it for another purpose and i edited all the stuff that need change but now I suddenly run into an error on a line which makes no sense.. Can someone take a look what is wrong here?

 

Notice: Undefined variable: mysqli in /home/schoolme/public_html/view.php on line 23

Fatal error: Call to a member function query() on a non-object in /home/schoolme/public_html/view.php on line 23

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
        <head>  
                <title>View Records</title>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        </head>
        <body>
                
                <h1>View Records</h1>
                
                <p><b>View All</b> | <a href="view-paginated.php">View Paginated</a></p>
                
                <?php
                
                    # errors weergeven
                    ini_set('display_errors',1); // 1 == aan , 0 == uit
                    error_reporting(E_ALL | E_STRICT);
                
                        // connect to the database
                        include('db_config.php');
                        
                        // get the records from the database
                        if ($result = $mysqli->query("SELECT * FROM scholen ORDER BY naam"))
                        {
                                // display records if there are records to display
                                if ($result->num_rows > 0)
                                {
                                        // display records in a table
                                        echo "<table border='1' cellpadding='10'>";
                                        
                                        // set table headers
                                        echo "<tr><th>id</th><th>Naam</th><th>Type</th><th>Geloof</th><th>Adres</th><th>Postcode</th><th>Plaats</th><th>Provincie</th><th>Telefoon</th><th>Fax</th><th>E-mail</th><th>Website</th><th></th><th></th></tr>";
                                        
                                        while ($row = $result->fetch_object())
                                        {
                                                // set up a row for each record
                                                echo "<tr>";
                                                echo "<td>" . $row->id . "</td>";
                                                echo "<td>" . $row->naam . "</td>";
                                                echo "<td>" . $row->type . "</td>";
                                                echo "<td>" . $row->geloof . "</td>";
                                                echo "<td>" . $row->adres . "</td>";
                                                echo "<td>" . $row->postcode . "</td>";
                                                echo "<td>" . $row->plaats . "</td>";
                                                echo "<td>" . $row->provincie . "</td>";
                                                echo "<td>" . $row->telfoon . "</td>";
                                                echo "<td>" . $row->fax . "</td>";
                                                echo "<td>" . $row->email . "</td>";
                                                echo "<td>" . $row->website . "</td>";
                                                echo "<td><a href='records.php?id=" . $row->id . "'>Edit</a></td>";
                                                echo "<td><a href='delete.php?id=" . $row->id . "'>Delete</a></td>";
                                                echo "</tr>";
                                        }
                                        
                                        echo "</table>";
                                }
                                // if there are no records in the database, display an alert message
                                else
                                {
                                        echo "No results to display!";
                                }
                        }
                        // show an error if there is an issue with the database query
                        else
                        {
                                echo "Error: " . $mysqli->error;
                        }
                        
                        // close database connection
                        $mysqli->close();
                
                ?>
                
                <a href="records.php">Add New Record</a>
        </body>
</html>
Link to comment
https://forums.phpfreaks.com/topic/282379-mysqli-view-script/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.