다음은 현재 가지고있는 PHP 코드 예제입니다. 테이블에서 한 행을 가져오고 싶지만이 오류를 반환합니다.PHP를 사용하여 mySQL 테이블에서 한 행의 데이터를 얻으려면 어떻게해야합니까?
Call to a member function fetch_assoc() on a non-object
아무런 통찰력을 얻을 수 있습니다.
$pathname = "C:\Users\BL\Documents\GitHub\Moozik\music";
$files = scandir($pathname);
$server = "localhost";
$user = "root";
$pass = "";
while ($files[0] == "." || $files[0] == "..") {
array_shift($files);
}
print_r($files);
$song = $pathname . '\\' . $files[0];
$conn = new mysqli($server, $user, $pass);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT song_path FROM song_data";
$result = mysqli_query($conn, $sql);
while($row = $result->fetch_assoc()) {
$its = $row["song_path"];
printf($its);
}
mysqli_close($conn);
당신은 나는 이것이 시작이다 가정 –
물론 @IndraKumarS 시도 할 수있다! mysqli_fetch_row()가 mysqli_result' 매개 변수 1을 기대하고 있습니다. @vignesh – MontyTheMack