本來資料是會顯示在表格裡 可是他跑出一堆錯誤
下面是原程式碼 求邦友救救菜鳥我
<?php
header('content-type: text/html; charset=utf-8');
include "db.php";
$aa = $_POST['username'];
$bb = $_POST['passwd'];
$birth = $_POST['birth'];
$years = $_POST['years'];
$note = $_POST['note'];
$gender = $_POST['gender'];
$blood = $_POST['blood'];
$email = $_POST['email'];
echo '帳號:' . $aa . "<br />" ;
echo '密碼:' . $bb . "<br />" ;
echo '生日:' . $birth . "<br />" ;
echo '年紀:' . $years . "<br />" ;
echo '性別:' . $gender . "<br />" ;
echo '血型:' . $blood . "<br />" ;
echo "興趣:";
$h="";
if (isset($_POST['movie'])) {
$movie = $_POST['movie'];
$h = $h . $movie . '+';
echo "$movie ";
}
if (isset($_POST['sudo'])) {
$sudo = $_POST['sudo'];
$h = $h . $sudo . '+';
echo "$sudo ";
}
if (isset($_POST['read'])) {
$read = $_POST['read'];
$h = $h . $read . '+';
echo "$read ";
}
echo "<br />";
$upload_dir='./upload/';
//如果錯誤代碼為 UPLOAD_ERR_OK, 表示上傳成功
if( $_FILES['upfile']['error'] == UPLOAD_ERR_OK ) {
//將暫存檔搬移到上傳目錄下, 並且改回原始檔名
$tmp = $_FILES['upfile']['tmp_name'];
$photo = $_FILES['upfile']['name'];
move_uploaded_file($tmp, $upload_dir . $photo);
echo "相片:$photo<br />";
}
else{
$photo = "";
echo "上傳失敗<br /><br />";
}
echo '信箱:' . $email . "<br />" ;
echo '留言板:' . nl2br($note) . "<br />" ;
$result = mysqli_query($conn, "select * from `$tbName` where 帳號 = '$aa'");
if (mysqli_num_rows($result) > 0) {
echo " <br />資料庫中已有 '$aa' 帳號!!!";
echo '<meta http-equiv=REFRESH CONTENT=5;url=index.htm>';
}
else
{
$sql = "INSERT $tbName (`帳號`,`密碼`,`生日`,`年紀`,`性別`,`血型`,`興趣`,`相片`,`信箱`,`留言板`)
VALUES ('$aa','$bb','$birth','$years','$gender','$blood','$h','$photo','$email','$note')";
echo $sql;
$result = mysqli_query($conn, $sql);
if (!$result)
echo("<br />" . "新增失敗:" . mysqli_error($conn));
// else
// include "gmail.php";
echo "<table border=1><tr>";
echo "<th>帳號</th><th>密碼</th><th>生日</th><th>年紀</th><th>性別</th><th>血型</th><th>興趣</th><th>相片</th><th>信箱</th><th>留言板</th></tr>";
$result=mysqli_query($conn, "SELECT * FROM `$tbName`");
//--------------- 讀取資料庫記錄 ---------------
while ($row=mysqli_fetch_array($result))
{
// echo "$row[0]" . "$row[1]" . "<br />";
// echo "{$row['帳號']}" . "{$row['密碼']}" . "<br />";
echo "<tr>";
echo "<td>$row[0]</td>";
echo "<td>$row[1]</td>";
echo "<td>$row[2]</td>";
echo "<td>$row[3]</td>";
echo "<td>$row[4]</td>";
echo "<td>$row[5]</td>";
echo "<td>";
$hh = explode('+',$row[6]);
for ($i=0; $i<count($hh); $i++) echo "$hh[$i] ";
echo "</td>";
echo "<td><img src='$upload_dir$row[7]'></td>";
echo "<td>$row[8]</td>";
echo "<td>" . nl2br($row[9]) . "</td>";
echo "</tr>";
// echo "<td><img src='$upload_dir/$row[6]'></td>";
}
echo "</table>";
mysqli_close($conn);
}
?>
感謝各位我解決了 原來是我phpmyadmi沒設欄位==
在 64 行 $result 前面插入 echo $sql 看回傳甚麼,
再將那段 sql 貼到 mysql 看出現甚麼錯誤。