dtbiszu7724 2018-08-27 20:45
浏览 32

该函数不与查询连接到数据库

I am using a function that is supposed to get the result row as an associative array but it does not get me because it changes from mysql to mysqli according to the moderator's instructions.

What am I doing wrong

function dbquery($link,$query) {

    $result = mysqli_query($link, $query );
    if (!$result) {
        echo mysqli_connect_error();
        return false;
    } else {
        return($result);

    }
    mysqli_close($link);
}

Function to connect to the database

function dbconnect($db_host, $db_user, $db_pass, $db_name) {
    global $db_connect;
    $db_connect = mysqli_connect($db_host, $db_user, $db_pass);
    $db_select = mysqli_select_db($db_connect, $db_name);
    if (!$db_connect) {
        die("<div style='font-family:Verdana;font-size:11px;text-align:center;'><b>Unable to establish connection to MySQL</b><br />".mysqli_connect_error()." : ".mysqli_connect_error()."</div>");
    } elseif (!$db_select) {
        die("<div style='font-family:Verdana;font-size:11px;text-align:center;'><b>Unable to select MySQL database</b><br />".mysqli_connect_error($db_name)." : ".mysqli_connect_error()."</div>");
    }

}
$link = dbconnect($db_host, $db_user, $db_pass, $db_name);

What is wrong ??


Notice: Undefined index: siteurl in /home/sfera/public_html/locale/Polish-utf8/global.php on line 132

Notice: Undefined index: siteurl in /home/sfera/public_html/locale/Polish-utf8/global.php on line 140

Notice: Undefined index: siteurl in /home/sfera/public_html/locale/Polish-utf8/global.php on line 147

You know how to remove this error the error is from the locale. I will show you that you know what's going on

    $locale['global_441'] = "Your account on ".$settings['sitename']."has been banned";
$locale['global_442'] = "Hello [USER_NAME],

Your account on ".$settings['sitename']." was caught posting too many items to the system in very short time from the IP ".USER_IP.", and have therefor been banned. This is done to prevent bots from submitting spam messages in rapid succession.

Please contact the site administrator at ".$settings['siteemail']." to have your account restored or report if this was not you causing this security ban.

".$settings['siteusername'];
// Lifting of suspension
$locale['global_450'] = "Suspension automatically lifted by system";
$locale['global_451'] = "Suspension lifted at ".$settings['sitename'];
$locale['global_452'] = "Hello USER_NAME,

The suspension of your account at ".$settings['siteurl']." has been lifted. Here are your login details:

Username: USER_NAME
Password: Hidden for security reasons

If you have forgot your password you can reset it via the following link: LOST_PASSWORD


Regards,

".$settings['siteusername'];
$locale['global_453'] = "Hello USER_NAME,

The suspension of your account at ".$settings['siteurl']." has been lifted.


Regards,

".$settings['siteusername'];
$locale['global_454'] = "Account reactivated at ".$settings['sitename'];
$locale['global_455'] = "Hello USER_NAME,

Last time you logged in your account was reactivated at ".$settings['siteurl']." and your account is no longer marked as inactive.


Regards,

It makes me an argument from the base though I have it in function

// Fetch the Site Settings from the database and store them in the $settings variable

$settings = dbarray(dbquery($link,"SELECT * FROM ".$db_prefix."setting"));

So this is but the locale do not want to read them

  • 写回答

3条回答 默认 最新

  • duanboshi1472 2018-08-27 20:55
    关注

    Not use MySQL or MySQLi. Use PDO:

    ob_start();
    session_start();
    $db_hostname = "localhost";
    $db_username = "root";
    $db_password = "";
    $db_name = "XXXXXX";
    #error_reporting(0);
    #error_reporting(E_ALL);
    #ini_set('display_errors', 1);
    try {
    $dbh = new PDO("mysql:host=$db_hostname;dbname=$db_name", $db_username, $db_password);
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    } catch (PDOException $e) {
        echo $e->getMessage()."<br/>";
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求帮我调试一下freefem代码
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图