arjanvr Posted September 23, 2013 Share Posted September 23, 2013 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 23Fatal 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> Quote Link to comment https://forums.phpfreaks.com/topic/282379-mysqli-view-script/ Share on other sites More sharing options...
Ch0cu3r Posted September 23, 2013 Share Posted September 23, 2013 PHP cannot find the variable $mysqli. I assume this is defined in db_config.php Are you sure this file exists and that you have spelt the variable correctly? Quote Link to comment https://forums.phpfreaks.com/topic/282379-mysqli-view-script/#findComment-1450816 Share on other sites More sharing options...
arjanvr Posted September 23, 2013 Author Share Posted September 23, 2013 Now that was pretty dumb. I used a differnent db_config file this time which was still from the SQL version. Fixing the db_config solved the problem. Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/282379-mysqli-view-script/#findComment-1450820 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.