dames
dames

Reputation: 1481

mysql to mysqli expects parameter error

So I dug up an old application I had developed in php ver. 4., mysql 4. so i restored it in Wamp, running php ver. 5.5. and mysql 5.6.**

However, what I am realizing is the old mysql_query,mysql_select_db,mysql_connect need to be changed to mysqli_.

I am getting the following errors:

Warning: mysqli_select_db() expects parameter 1 to be mysqli

and I am not exactly sure if I am to go through and change all mysql_ to mysqli_

Upvotes: 0

Views: 48

Answers (1)

Funk Forty Niner
Funk Forty Niner

Reputation: 74217

Make sure there are no instances of mysql_ anywhere; connection also. mysqli_select_db() needs to be something like mysqli_select_db($con, $database)

mysql_ and mysqli_ functions do not mix together.

However, mysqli_ works differently than mysql_ so you may have to do a few adjustments along the way, such as using mysqli_real_escape_string() for instance; it needs DB connection.

I.e.: mysqli_real_escape_string($con, $variable)

Since you're getting started into using mysqli_ functions, look into using mysqli with prepared statements, or PDO with prepared statements, it's much safer.

Upvotes: 2

Related Questions