php - How to fix: Warning: mysqli_get_server_info() expects parameter 1 to be mysqli? -
i'm bad in php , i'm trying install arfoo.com on host. had problem mysql , mysqli, fixed now.
but error:
warning: mysqli_get_server_info() expects parameter 1 mysqli, string given in /home/***/install/step4.php on line 47
for following code:
<?php /** * arfooo * * @package arfooo * @copyright copyright (c) arfooo annuaire (fr) , arfooo directory (en) * guillaume hocine (c) 2007 - 2010 * http://www.arfooo.com/ (fr) , http://www.arfooo.net/ (en) * @author guillaume hocine & adrian galewski * @license http://creativecommons.org/licenses/by/2.0/fr/ creative commons */ session_start(); error_reporting(e_all); require_once('languages/' . $_session['selectedlanguage'] . '.php'); $chemin_includes_header = 'includes/'; include_once($chemin_includes_header.'header.php'); require_once("dbfunctions.php"); require_once("createdb.php"); function createdbconfig($dbhost, $dbuser, $dbpass, $dbname, $dbprefix) { $dbconfig['db_host'] = $dbhost; $dbconfig['db_user'] = $dbuser; $dbconfig['db_pass'] = $dbpass; $dbconfig['db_name'] = $dbname; $dbconfig['db_prefix'] = $dbprefix; $dbconfig['db_installed'] = true; $data = "<?php\n \$dbconfig = " . var_export($dbconfig, true). ";\n ?>"; file_put_contents("../config/db.php", $data); } $_session['mysqlserver'] = $_post['mysqlserver']; $_session['mysqluser'] = $_post['mysqluser']; $_session['mysqlpassword'] = $_post['mysqlpassword']; $_session['mysqldatabasename'] = $_post['mysqldatabasename']; $_session['mysqltablesprefix'] = $_post['mysqltablesprefix']; dbconnect($_session['mysqlserver'], $_session['mysqluser'], $_session['mysqlpassword'], $_session['mysqldatabasename'] ); $mysqlversion = mysqli_get_server_info(); $mysqlversioncorrect = version_compare($mysqlversion, "4.1", ">="); if($mysqlversioncorrect) { createdbconfig($_post['mysqlserver'], $_post['mysqluser'], $_post['mysqlpassword'], $_post['mysqldatabasename'], $_post['mysqltablesprefix']); $tableslist = createdbtables($_post['mysqltablesprefix'], $_session['siterooturl'], $_session['selectedlanguage'], $_session['urlrewriting'] ); } else { $tableslist = array(); } ?>
edit:
function dbconnect($server, $user, $pass, $dbname) { /* install database prefixed tables */ $conn = mysqli_connect($server, $user, $pass, $dbname); //mysql_connect($server, $user, $pass) or die('could not connect mysql');; mysqli_query($conn, 'create temporary table table'); //mysqli_query($dbname, 'create temporary table `table`'); //mysql_query('create database if not exists ' . $dbname); mysqli_select_db($conn, $dbname) or die('could not select database'); }
any kind highly appreciated!
you should pass object returned mysqli_connect()
argument mysqli_get_server_info()
if want use procedural style.
$mysqlconnect = mysqli_connect("localhost", "my_user", "my_password"); $mysqlversion = mysqli_get_server_info($mysqlconnect);
or using oo style :
$mysqlconnect = new mysqli("localhost", "my_user", "my_password"); $mysqlversion = $mysqlconnect->server_info;
see more @ http://php.net/mysqli_get_server_info
edit :
your dbconnect() function should return mysqli object, try add return $conn;
@ end, :
function dbconnect($server, $user, $pass, $dbname) { /* install database prefixed tables */ $conn = mysqli_connect($server, $user, $pass, $dbname); //mysql_connect($server, $user, $pass) or die('could not connect mysql');; mysqli_query($conn, 'create temporary table table'); //mysqli_query($dbname, 'create temporary table `table`'); //mysql_query('create database if not exists ' . $dbname); mysqli_select_db($conn, $dbname) or die('could not select database'); return $conn; }
Comments
Post a Comment