簡體   English   中英

查詢似乎不起作用

[英]Query doesn't seem to work

我有一個登錄表單,要求輸入用戶名,密碼和包含密鑰字符串的文件。 我想將此文件中的密鑰與數據庫中的密鑰進行比較,如果一切都匹配,則用戶登錄。 問題在於此查詢似乎不起作用:

$userBusca = mysqli_query($conn, "SELECT * FROM account.login_admin WHERE login='".$login."' AND password='".$password."' AND key='".$key."'") or die(mysql_error());
if($userBusca->num_rows == 1) {

它向我顯示此錯誤,但是我的mysqli連接正在工作:

警告:mysqli_connect()期望參數1為字符串,第3行的D:\\ xampp \\ htdocs \\ admin \\ auth \\ login.php中給出的對象

這是我的第3行:

$dbcon = mysqli_connect($conn, "5.xx.xx.xxx","user","xxxxxx");

我正在用此獲取用戶文件的內容:

$file = $_FILES['file'];
$file_name = $file['name'];
$file_tmp = $file['tmp_name'];
$file_size = $file['size'];
$file_error = $file['error'];
//whitelist
$file_ext = explode('.', $file_name);
$file_ext = strtolower(end($file_ext));
$allowed = array('txt', 'cfg');
if(in_array($file_ext, $allowed)) {
if ($file_error === 0) {
    if($file_size <= 2097152) {
        $file_name_new = uniqid('', true) . '.' . $file_ext;
        $file_destination = 'uploads/' . $file_name_new;
        if(move_uploaded_file($file_tmp, $file_destination)) {
            $key_read_file = $file_destination;
            $key_load = file_get_contents($key_read_file);
            $key = $key_load;
            echo $key;

回聲返回我想要的正確結果,但是由於某種原因,錯誤不斷彈出。

提前致謝

首先完美獲得功能

$conn = mysqli_connect("myhost","myuser","mypassw","mybd");

所以你會像

$dbcon = mysqli_connect("5.xx.xx.xxx","user","xxxxxx","your_db");

我認為您正在混合使用mysqlimysql擴展,這將無法正常工作。 您需要使用。

$myConnection= mysqli_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql"); 

mysqli_select_db("databasename") or die ("no database");   

mysqli對原始mysql擴展進行了許多改進

這個 :

 $dbcon = mysqli_connect($conn, "5.xx.xx.xxx","user","xxxxxx");

應該是這樣的:

 $dbcon = mysqli_connect("5.xx.xx.xxx","user","xxxxxx");

和這個 :

 mysqli_query($conn

應該是這樣的:

 mysqli_query($dbcon

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM