codeigniter - why am i getting an error from file mysqli/mysqli_driver.php?

885

I have just uploaded my project to my website server and i am getting this error message when i click on my submit button for my logging in form.

A PHP Error was encountered
Severity: Warning

Message: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given

Filename: mysqli/mysqli_driver.php

Line Number: 315

I have absolutely no errors on my local server and i am completely stumped on what the problem is. if some one could please help i would be greatly appreciative and much respect will be given.

My project is using codeigniters framework.

601

Answer

Solution:

mysqli_real_escape_string() is used to prepare text data too be save in an SQL Record Column.<br>And the data being wrint to that column does not exist.<br><br>

Go tomysqli_driver.php to Line #315 and put an at mark in fron of the command to supress the warning.

From:

 mysqli_real_escape_string() 

To:

 @mysqli_real_escape_string() 

If the value you are escaping is an integer, then use intval() instead:
This will turn a NULL into a Zero

$var = intval($var);
308

Answer

Solution:

Instead of hide warnings with @, check that conn_id is not false:

change

 $str = mysqli_real_escape_string($this->conn_id, $str);

like that

if($this->conn_id){
    $str = mysqli_real_escape_string($this->conn_id, $str);
}
842

Answer

Solution:

My solution was to initialize the connection if it is not available. Change line #315:

if ($this->conn_id === FALSE)
{
    $this->initialize();
}
$str = mysqli_real_escape_string($this->conn_id, $str); 
782

Answer

Solution:

I met this problem too. Wolfgang's solution works well for me.

And if you use codeIgniter, change database config$db['default']['autoinit'] = TRUE; can also solve the problem.

People are also looking for solutions to the problem: php - Undefined index notice while requesting ajax with HTML5 pushstate

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.