這是我的代碼,但我不知道錯誤在哪裏。
它說,我有錯誤,是通知:
Undefined index: ic in C:\xampp\htdocs\fyp\profile.php on line 57.
<?php
include_once("config.php");
$ic = $_SESSION['ic'];//-----------------------------------this is line 57
$sql = "SELECT * FROM studentprofile WHERE ic = '$ic'";
$result = mysql_query($sql,$conn);
while($row = mysql_fetch_array($result))
{
$id = $row['id'];
$ic = $row['ic'];
$name = $row['name'];
$course = $row['course'];
$faculty = $row['faculty'];
$address = $row['address'];
$hpno = $row['hpno'];
$gender = $row['gender'];
$email = $row['email'];
?>
<table width="70%" height="80%" border="1" align="center">
<tr>
<th>ID</th>
<td><?php echo $id;?></td>
</tr>
<tr>
<th>IC No</th>
<td><?php echo $ic;?></td>
</tr>
<tr>
<th>Name</th>
<td><?php echo $name;?></td>
</tr>
<tr>
<th>Course</th>
<td><?php echo $course;?></td>
</tr>
<tr>
<th>Faculty</th>
<td><?php echo $faculty;?></td>
</tr>
<tr>
<th>Address</th>
<td><?php echo $address;?></td>
</tr>
<tr>
<th>Handphone No</th>
<td><?php echo $hpno;?></td>
</tr>
<tr>
<th>Gender</th>
<td><?php echo $gender;?></td>
</tr>
<tr>
<th>Email</th>
<td><?php echo $email;?></td>
</tr>
</table>
<?php
}
?>
我想嘗試把isset。但我不知道如何。我已經嘗試刪除include_once(「config.php」)以包含(「config.php」)..但沒有發生任何事情。
我已經開始在PHP中的會話。任何人都可以幫我找出我的編碼有什麼問題嗎?
此編碼用於查看已登錄系統的人的個人資料。例如,我登錄到系統,當我查看個人資料時,只會顯示我的個人資料。因此,我嘗試使用之前發佈的代碼。
但它是錯誤的。我已經將數據庫中的ic屬性設置爲主鍵。
當您設置$ _SESSION ['ic']的值? –
你開始會話嗎?否則檢查'$ ic = isset($ _SESSION ['ic'])? $ _SESSION ['ic']:'';' –
yes sir.i已經開始會話。 – april