<?php
$uname = $_POST["username"]$uname =
stripslashes(trim($uname));
$pward = $_POST["password"];
$pward = stripcslashes(trim($pward));
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "index_data";
$conn = new mysqli($servername, $username,
$password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM 00_user_details WHERE
username = '$uname' ";
$result = mysqli_query($conn, $sql);
$rows = mysqli_fetch_row($result);
echo "_".$rows["first_name"]."_";
?>
我更大。 这是我的代码,但什么都不输出。 如果您尊敬的话,先生/可以帮我...
答案 0 :(得分:0)
请在$ _POST [“ username”]后加分号,并使用mysqli_fetch_assoc代替mysqli_fetch_row。
mysqli_fetch_assoc返回一行作为关联数组,其中列名将是存储相应值的键。
请找到以下实际代码:
$uname = $_POST["username"];
$uname = stripslashes(trim($uname));
$pward = $_POST["password"];
$pward = stripcslashes(trim($pward));
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "index_data";
$conn = new mysqli($servername, $username,$password, $dbname);
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM 00_user_details WHERE username = '$uname'";
$result = mysqli_query($conn, $sql);
$rows = mysqli_fetch_assoc($result);
echo "_".$rows["first_name"]."_";