大家好我试图检查我的MYSQL DB中是否存在值(令牌)。
主要信息:
表:代币 专栏:令牌
我的最新尝试:
<?php
// DATABASE STUFF
$servername = "localhost";
$username = "userhere";
$password = "passhere";
$dbname = "zwinky";
$token = $_GET['a'];
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$result = mysql_query("SELECT * FROM Tokens WHERE Token = '$token'");
$matchFound = mysql_num_rows($result) > 0 ? 'yes' : 'no';
echo $matchFound;
?>
有没有人有想法?
答案 0 :(得分:0)
如果您使用mysqli_*
,则无法使用mysql_*
试试这个
<?php
// DATABASE STUFF
$servername = "localhost";
$username = "userhere";
$password = "passhere";
$dbname = "zwinky";
$token = $_GET['a'];
$con=mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (mysqli_connect_errno()){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// Perform queries
$result = mysqli_query($con,"SELECT * FROM Tokens WHERE Token = '$token'");
$matchFound = mysqli_num_rows($result) > 0 ? 'yes' : 'no';
echo $matchFound;
?>