나는 PHP의 초보자입니다. 내 PHP 파일에서 다음 코드를 실행하려고하지만 데이터가 내 SQL 테이블에 동일한 항목으로 존재하지만 아무 결과 나 가져 오는 것입니다.PHP MAMP의 결과가 없습니다. MySQL 쿼리
<?php
echo "this is the start";
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "PW3";
$conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
echo "Unable to connect to databse";
die("Connection failed: " . mysqli_connect_error());
}
else {
echo "Connected";
if(!empty($_POST["username"]) && !empty($_POST["password"])){
$username=$_POST['username'];
//echo "$username";
$sql="SELECT fullname FROM `users` WHERE username=ashish";
$result1=mysqli_query($conn,$sql);
print_r($result1);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result1);
echo "$count";
}
}
echo "<br>this is the end";
?>
WHERE username = ashish "를 WHERE username = 'ashish'로 변경하고 이것이 도움이되는지 확인하십시오. 그렇지 않으면 반환되는 오류 메시지를 게시하십시오. – jeff
@jeff : $ result1에 대한 결과를 얻지 만'echo "$ count"'에 대한 결과가 없습니다. 또한 다음과 같이 지정하고 싶습니다.'$ sql = "SELECT fullname FROM users where WHERE username = $ username"; ' 여기서 다시 결과를 가져 오지 않습니다. – CodeHunter
@ashishkumar 당신은 그'print_r' 후에 아무 것도 얻지 못한다는 것을 의미합니까? 또는 "$ count"또는 0 또는 무엇인가 얻을 수 있습니까? – Albert221