내 <?php
이 ?>
이 아니라 내 첫 번째 >
에서 닫히는 것 같아서 PHP 스크립트에서 내 SQL을 실행하는 데 문제가 있습니다. 특히 첫 번째 에코 라인 및 >
에서 계속 실행되는 대신 중지됩니다. 내가 도대체 뭘 잘못하고있는 겁니까?첫 번째 대신에 PHP가 끝나는가?>
<?php
$q = intval($_GET['q']);
$con = mysqli_connect('localhost','peter','abc123','my_db');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"ajax_demo");
$sql="SELECT * FROM user WHERE id = '".$q."'";
$result = mysqli_query($con,$sql);
echo "<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
<th>Hometown</th>
<th>Job</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['FirstName'] . "</td>";
echo "<td>" . $row['LastName'] . "</td>";
echo "<td>" . $row['Age'] . "</td>";
echo "<td>" . $row['Hometown'] . "</td>";
echo "<td>" . $row['Job'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
이 코드는 자습서에서 복사/붙여 넣기되었습니다.
실행이 중지되는 위치는 어디입니까? –
당신은 그것이 멈추고 있는지, 아니면 당신이 브라우저에서 보았던 것일까? 브라우저에서 페이지를 열지 않고 실제 웹 서버에서 페이지를 실행하고 있는지 확인하십시오 (주소 표시 줄에 'http : //'가 나타나야합니다. 'file : ///'이 아닙니다. – aynber