将ID插入数据库

时间:2016-07-13 16:33:35

标签: php mysql

所以我正在建立一个网站,当他们登录时需要连接到我的数据库。登录时,它会检索用户ID。但我得到了代码工作,没有错误,但是当我查看我的数据库时,它得到了一个ID的随机数并存储了。那么我做错了什么?

<?php
require 'steamauth/steamauth.php';

if(!isset($_SESSION['steamid'])) {

$username = "Unknown";
$avatar = "defaultUser";
$accid = "Unknown";

$avatarSmall = "smallUser"; //For Dashboard

} else {

include ('steamauth/userInfo.php');

$username = &$steamprofile['personaname'];
$avatar = &$steamprofile['avatarmedium'];
$accid = &$steamprofile['steamid'];

$avatarSmall = &$steamprofile['avatar']; //For Dashboard

include('connect-mysql.php');

if(!$dbcon){
    die('Database Failed To Connect.');
}else{
    $checkUserID = mysqli_query($dbcon, "SELECT userID from userData WHERE userID = '&$accid'");
        if(!$checkUserID){
            die('Server Failed To Respond.');
        }else{
            if(mysqli_num_rows($checkUserID) > 0) {
                $getCredits =mysqli_query($dbcon, "SELECT userCredits from userData WHERE userID = '&$accid'");
            }else{
                $sqlinsert = "INSERT INTO userData (userID, userCredits) VALUES ('&$accid', '0')";
                if(!mysqli_query($dbcon, $sqlinsert)){
                    die('Server Failed To Respond To Query.');
                }
            }
        }
    }  
}



?>

但它很奇怪,因为当我在我的html代码中使用$ accid时,它会显示正确的数字。

有什么想法吗?

谢谢,

马特

0 个答案:

没有答案