简体   繁体   中英

how to run mysqli server on appserv 2.5.10?

I am trying use mysqli functions but I get this error:

Fatal error: Call to undefined method mysqli::num_rows() in C:\AppServ\www\edu\files\header.php on line 19

I tried to go to php.ini and remove ; from extension=php_mysqli.dll I found it already removed

I tried to restart appachi; the connection file:

// db username
define("USERNAME","root");

// db password
define("PASSWORD","root");

// db servername
define("SERVERNAME","localhost");

// db name
define("NAME","edu");

//connect to db
$mysqli = new mysqli(SERVERNAME,USERNAME,PASSWORD,NAME);
if ($mysqli->connect_errno) {
    echo $cannot_connect;
}

//select db encoding
$mysqli->set_charset('utf8');   

calling function in a file:

$sql = $mysqli->query("SELECT VALUE FROM SITE_CONFIG WHERE CONF='KEYWORDS'");
if (!$sql) {
    echo "Failed to run query: (" . $mysqli->errno . ") " . $mysqli->error;
}
if($mysqli->num_rows($sql) > 0){
    while($rs = $sql->fetch_assoc()){
        $keyw = $rs['VALUE'];
    }
}else{
        $keyw = $no_data;
}

note : I included connection.php

Try:

$sql = $mysqli->query("SELECT VALUE FROM SITE_CONFIG WHERE CONF='KEYWORDS'");
if (!$sql) {
    echo "Failed to run query: (" . $mysqli->errno . ") " . $mysqli->error;
} else {
    if($sql->num_rows > 0){// here must be $sql , not $mysqli
        while($rs = $sql->fetch_assoc()){
            echo $rs['VALUE'];
        }
    } else{
            echo "No data";
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM