Thread subject: pHpFusion Nederlands (BE|NL) » Ondersteuning, Themas, Infusies, Modificaties en Installatie :: Autonews Infusion

Posted by douwe_yntema on 24 februari 2019, 16:26
#2

mysql_result is deprecated in php5.6 and removed in php 7.0, so it is not recommend to use this function


You should use the function dbcount from maincore

It should be something like:

$rtn = dbcount("somefield", DB_USERS, "autonews='1'")

Code

**
 * Count the number of rows in a table filtered by conditions
 *
 * @global int   $mysql_queries_count
 * @global array $mysql_queries_time
 *
 * @param string $field      Parenthesized field name
 * @param string $table      Table name
 * @param string $conditions conditions after "where"
 *
 * @return boolean
 */
function dbcount($field, $table, $conditions = "") {
    $cond = ($conditions ? " WHERE ".$conditions : "");
    $sql = "SELECT COUNT".$field." FROM ".$table.$cond;
    try {
        $statement = dbconnection()->prepare($sql);
        $statement->execute();
        return $statement->fetchColumn();
    } catch (PDOException $e) {
        trigger_error($e->getMessage(), E_USER_ERROR);
        echo $e;
        return FALSE;
    }
}

Edited by douwe_yntema on 24 februari 2019, 16:31