Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   TBDev (http://www.bvlist.com/forumdisplay.php?f=20)
-   -   Doesn't work with mysqli! (how to fix) (http://www.bvlist.com/showthread.php?t=11783)

BT-loader 12th October 2018 14:52

Doesn't work with mysqli! (how to fix)
 
Is there anyone who has go this to work with the forced use of mysqli?

DND 12th October 2018 14:53

simple.. change all your code to mysqli:coffee:

Napon 12th October 2018 15:45

OK pm me what code and all I can mysqli it for you


If you wait 2 weeks I'll be uploading my FMEDITION 18 mysqli to my github

Tedmorris 21st November 2018 21:59

Besides changing mysql_* calls to mysqli_* what are the functions that need to be updated etc. Ive seen some TBDEV mods with mysqli_* but cant seem to find any showing the updated functions related to the db like dbconn()

DND 21st November 2018 23:25

if you use standard tbdev.. this should do the trick


Code:

function dbconn($autoclean = false)
{
global $TBDEV;

if (!@($GLOBALS["___mysqli_ston"] = mysqli_connect($TBDEV['mysql_host'],  $TBDEV['mysql_user'],  $TBDEV['mysql_pass'])))
{
switch (((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_errno($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_errno()) ? $___mysqli_res : false)))
{
case 1040:
case 2002:
if ($_SERVER['REQUEST_METHOD'] == "GET")
die("

The server load is very high at the moment. Retrying, please wait...

");
else
die("Too many users. Please press the Refresh button in your browser to retry.");
default:
die("[" . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_errno($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_errno()) ? $___mysqli_res : false)) . "] dbconn: mysql_connect: " . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
}
}
((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE {$TBDEV['mysql_db']}"))
or die('dbconn: mysql_select_db: ' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));

userlogin();

if ($autoclean)
register_shutdown_function("autoclean");
}


Tedmorris 22nd November 2018 00:07

Thx DND, i use a heavy modified TBsource but that should do the trick, is there anything else that needs to be changed? And one last thing, i notice some calls are not changed in some code, how do i tell which ones to leave as mysql_* and which ones to change to mysqli_* ?

DND 22nd November 2018 00:27

Basic example:


Code:

mysql_query('SELECT username FROM users WHERE id = ' . sqlesc($user['invitedby']));
will become

Code:

mysqli_query($GLOBALS["___mysqli_ston"], 'SELECT username FROM users WHERE id = ' . sqlesc($user['invitedby']));

same query, just a bit changed

HDVinnie 23rd November 2018 05:06

Quote:

Originally Posted by Tedmorris (Post 52825)
Thx DND, i use a heavy modified TBsource but that should do the trick, is there anything else that needs to be changed? And one last thing, i notice some calls are not changed in some code, how do i tell which ones to leave as mysql_* and which ones to change to mysqli_* ?

Is this version on GitHub? Would make it easier to make a PR to show changes needed.

Tedmorris 24th November 2018 22:04

No mate its not but the orignal source would be. Whats a PR?

Napon 25th November 2018 01:28

mine is on github to mysqli

darkalchemy 25th November 2018 18:06

Quote:

Originally Posted by Tedmorris (Post 52834)
No mate its not but the orignal source would be. Whats a PR?

"PR" === Pull Request. It's how someone can make changes to your code and offer those changes to you.

Tedmorris 26th November 2018 03:26

Quote:

Originally Posted by Napon (Post 52835)
mine is on github to mysqli

Link?

Napon 19th October 2019 09:40

Code:

function dbconn($autoclean = false){
global $TBDEV;
if (!@($GLOBALS["___mysqli_ston"] = mysqli_connect($TBDEV['mysql_host'],  $TBDEV['mysql_user'],  $TBDEV['mysql_pass']))){
    switch (((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_errno($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_errno()) ? $___mysqli_res : false))) {
    case 1040:
    case 2002:
if ($_SERVER['REQUEST_METHOD'] == "GET")
    die("

The server load is very high at the moment. Retrying, please wait...

");
    else
    die("Too many users. Please press the Refresh button in your browser to retry.");
    default:
    die("[".((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_errno($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_errno()) ? $___mysqli_res : false))."] dbconn: mysql_connect: ".((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
    }
}
    ((bool)mysqli_query($GLOBALS["___mysqli_ston"], "USE {$TBDEV['mysql_db']}")) or die('dbconn: mysql_select_db: ' . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
    userlogin();
if ($autoclean)
    register_shutdown_function("autoclean");
}


BT-loader 2nd January 2020 15:27

Can you please fix the database connection for "tbdev-01-03-06" too?

PHP Code:

function dbconn($autoclean false)
{
    global 
$mysql_host$mysql_user$mysql_pass$mysql_db;

    if (!@
mysql_connect($mysql_host$mysql_user$mysql_pass))
    {
      switch (
mysql_errno())
      {
        case 
1040:
        case 
2002:
            if (
$_SERVER[REQUEST_METHOD] == "GET")
                die(
"<html><head><meta http-equiv=refresh content=\"5 $_SERVER[REQUEST_URI]\"></head><body><table border=0 width=100% height=100%><tr><td><h3 align=center>The server load is very high at the moment. Retrying, please wait...</h3></td></tr></table></body></html>");
            else
                die(
"Too many users. Please press the Refresh button in your browser to retry.");
        default:
            die(
"[" mysql_errno() . "] dbconn: mysql_connect: " mysql_error());
      }
    }
    
mysql_select_db($mysql_db)
        or die(
'dbconn: mysql_select_db: ' mysql_error());

    
userlogin();

    if (
$autoclean)
        
register_shutdown_function("autoclean");



smoky28 2nd January 2020 16:27

Simple formula in every function you need to call global $ mysqli; call and then the dbconn function can be omitted.

BT-loader 2nd January 2020 17:40

Quote:

Originally Posted by smoky28 (Post 54383)
Simple formula in every function you need to call global $ mysqli; call and then the dbconn function can be omitted.

It's not that simple.
I also need the dbconn()-function to be changed for MySQLi.

smoky28 2nd January 2020 17:54

Create mysqli.php include folder
add bittorrent.php.

require_once("mysqli.php");



and put the global $ mysqli line for each function or where blobal i have just paste the $ mysqli add-on and at the very bottom of mysqli php there is a database connection there and enter and enter the database entry. but if you get stuck on skype you will be happy to help.


Code:

global $mysqli;halt('The PHP MySQLi extension is not loaded,!', false);        parent::__construct($host, $user, $pass, $db);        if($this->connect_errno)            $this->halt('Could not connect to MySQL server,');            }    public function affected_rows()    {        return $this->affected_rows;    }    public function close()    {        return @parent::close();    }    public function escape($input)    {        return $this->real_escape_string($input);    }    public function query($query_str)    {        if (func_num_args() > 1)        {            $args = func_get_args();            unset($args[0]);            $args = array_map(array($this, "real_escape_string"), $args);            $query_str = vsprintf($query_str, $args);        }        $QueryTime = microtime(true);        $this->query_id = parent::query($query_str);        $QueryTime = microtime(true) - $QueryTime;        if ($this->debug)        {            $this->querydebug[] = array('time' => $QueryTime, 'sql' => $query_str);            $this->querytime += $QueryTime;        }        if(!$this->query_id)            $this->halt('Querly error: '.$query_str);        $this->queries++;        return $this->query_id;    }    public function fetch_array($query_id = -1, $datatype = 'assoc')    {        if($query_id != -1)            $this->query_id = $query_id;        if($datatype === 'num')            $datatype = MYSQL_NUM;        else            $datatype = MYSQL_ASSOC;        $this->record = $query_id->fetch_array($datatype);        return $this->record;    }        public function fetch_assoc($query_id = -1)    {        if($query_id != -1)            $this->query_id = $query_id;        $this->record = $query_id->fetch_array(MYSQL_ASSOC);        return $this->record;    }    public function fetch_row($query_id = -1)    {        if($query_id != -1)            $this->query_id = $query_id;        $this->record = $query_id->fetch_row();        return $this->record;    }    public function num_rows($query_id=-1)    {        if($query_id!=-1)            $this->query_id = $query_id;        return $query_id->num_rows;    }    public function free_result($query_id=-1)    {        if($query_id!=-1)            $this->query_id = $query_id;        return $query_id->free();    }    private function halt($errormsg, $mysqli = true)    {        if (!$this->showerr)            return;        if($mysqli)        {            $errormsg .= "\n";            $errormsg .= 'MySQLi error code: '.$this->errno."\n";            $errormsg .= 'MySQLi Problem Description: '.$this->error."\n";        }        $errormsg .= 'Time: '.date('Y-m-d H:i:s')  ."\n";        $errormsg .= 'Script: '.htmlspecialchars(getenv('REQUEST_URI'))  ."\n";        $errormsg .= 'Referer: '.htmlspecialchars(getenv('HTTP_REFERER')) ."\n";        die("

MySQLi error

".nl2br($errormsg));    }}$mysqli = new mysqlidb('localhost','user','pass','database');?>


Napon 2nd January 2020 19:07

Quote:

Originally Posted by BT-loader (Post 54382)
Can you please fix the database connection for "tbdev-01-03-06" too?

PHP Code:

function dbconn($autoclean false){    global $mysql_host$mysql_user$mysql_pass$mysql_db;    if (!@mysql_connect($mysql_host$mysql_user$mysql_pass))    {      switch (mysql_errno())      {        case 1040:        case 2002:            if ($_SERVER[REQUEST_METHOD] == "GET")                die("<html><head><meta http-equiv=refresh content="5 $_SERVER[REQUEST_URI]"></head><body><table border=0 width=100% height=100%><tr><td><h3 align=center>The server load is very high at the moment. Retrying, please wait...</h3></td></tr></table></body></html>");            else                die("Too many users. Please press the Refresh button in your browser to retry.");        default:            die("[" mysql_errno() . "] dbconn: mysql_connect: " mysql_error());      }    }    mysql_select_db($mysql_db)        or die('dbconn: mysql_select_db: ' mysql_error());    userlogin();    if ($autoclean)        register_shutdown_function("autoclean"); } 




yes i can fix this the above is wrong hes given you too lol


All times are GMT +2. The time now is 21:11.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.