Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP MySQLi query error inside class "mysqli_query() expects parameter 1 to be mysqli, null given"
    primarykey
    data
    text
    <p>I tried everything, I read other questions here in stackoverflow and I still cant fix this.</p> <p><strong>I know there is plenty other questions like this and answers, but none help me! Tried over 5 hours to figure out</strong></p> <p>Anyway I have the following:</p> <pre><code>class RecoverPas{ private $mysqli; public function __construct() { $this-&gt;newMessage(); //Allow new object access to default Error Messages. $this-&gt;deleteOldCodes(); //Delete reset codes older that a certain interval. $this-&gt;mysqli = new mysqli(DB_SERVER, DB_USER, DB_PASS, DB_NAME); $this-&gt;mysqli-&gt;set_charset("utf8"); if($this-&gt;mysqli === false) { user_error("Unable to connect to database via mysqli."); return false; } } public function deleteOldCodes(){ $query_deloldcodes = mysqli_query($this-&gt;mysqli, "delete FROM activereset WHERE date &lt; DATE_SUB(CURDATE(), INTERVAL '".$this-&gt;deloldcodeint."' DAY)"); if ( false===$query_deloldcodes ) { printf("error: %s\n", mysqli_error($this-&gt;mysqli)); } } } $forgotpass = new RecoverPas(); </code></pre> <p>About the mysqli connect , the db info is ok I defined the db info in other php file, and this mysqli conenct work in other class perfect, also I test if the defines works here and they are defined here too.</p> <p>As you see I tried to print the errors but no I keep getting only this :</p> <pre><code>Warning: mysqli_query() expects parameter 1 to be mysqli, null given in line 506 </code></pre> <p>Line 506 is <code>public function deleteOldCodes(){</code> that i put above , I dont get mysqli error so its seem That there is a conenction, and i try to printf the mysqli error and not working either.</p> <p>So what wrong here?</p>
    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.
 

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