Note that there are some explanatory texts on larger screens.

plurals
  1. POgetting fatal error in php
    primarykey
    data
    text
    <p>I am trying to resolve this issue. But couldnt do it. Please help</p> <p>I am trying to view all the records in my database, but getting " Fatal error: Call to a member function query() on a non-object ...." and its pointing to </p> <pre><code>if ($result = $mysqli-&gt;query("SELECT ProductName, Description, Price, Size FROM Products ORDER BY ProductID")) </code></pre> <p>Here is my Complete code</p> <pre><code>&lt;?php include('db_connect.php'); **$mysqli = new mysqli("localhost", "netelmbn", "password", "netelmbn"); if ($mysqli-&gt;connect_errno) { printf("Connect failed: %s\n", $mysqli-&gt;connect_error); exit(); }** if ($result = $mysqli-&gt;query("SELECT ProductName, Description, Price, Size FROM Products ORDER BY ProductID")) { if ($result-&gt;num_rows &gt; 0) { echo "&lt;table border='1' cellpadding='10'&gt;"; echo "&lt;tr&gt;&lt;th&gt;ProductID&lt;/th&gt;&lt;th&gt;ProductName&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;th&gt;Price&lt;/th&gt;&lt;th&gt;Size&lt;/th&gt;&lt;/tr&gt;"; while ($row = $result_fetch_object()) { echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $row-&gt;ProductID . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row-&gt;ProductName . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row-&gt;Description . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row-&gt;Price . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row-&gt;Size . "&lt;/td&gt;"; echo "&lt;td&gt;&lt;a href='records.php?ProductID=" . $row-&gt;ProductID . "'&gt;Edit&lt;/a&gt;&lt;/td&gt;"; echo "&lt;td&gt;&lt;a href='delete.php?ProductID=" . $row-&gt;ProductID . "'&gt;Delete&lt;/a&gt;&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; } else { echo "No results to display!"; } } else { echo "Error: " . $mysqli-&gt;error; } $mysqli-&gt;close(); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload