iT邦幫忙

0

php註冊介面錯誤請教 (以解決)

php
  • 分享至 

  • xImage

https://ithelp.ithome.com.tw/upload/images/20210615/20137574t1n7brBCiJ.png
https://ithelp.ithome.com.tw/upload/images/20210615/20137574HbjNrmaFpD.pnghttps://ithelp.ithome.com.tw/upload/images/20210615/20137574DLuM4FrPsT.png
本來資料是會顯示在表格裡 可是他跑出一堆錯誤
下面是原程式碼 求邦友救救菜鳥我

<?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沒設欄位==

先去搞清楚資料型別 array 關於 key & value 之間的關係
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

0
rogeryao
iT邦超人 7 級 ‧ 2021-06-15 12:57:53
最佳解答

在 64 行 $result 前面插入 echo $sql 看回傳甚麼,
再將那段 sql 貼到 mysql 看出現甚麼錯誤。

mark2020 iT邦新手 5 級 ‧ 2021-06-15 13:08:58 檢舉

https://ithelp.ithome.com.tw/upload/images/20210615/20137574IQQM5XSOmr.png
跑出這個錯誤

rogeryao iT邦超人 7 級 ‧ 2021-06-15 13:57:44 檢舉

在 64 行 $result 前面插入 echo $sql;

1
海綿寶寶
iT邦大神 1 級 ‧ 2021-06-15 13:47:58

https://ithelp.ithome.com.tw/upload/images/20210615/2000178781vmCSDIjQ.png

mark2020 iT邦新手 5 級 ‧ 2021-06-15 14:01:14 檢舉

好的謝謝

sky800219 iT邦新手 5 級 ‧ 2021-06-15 14:22:20 檢舉

學到一課 謝謝大大

我要發表回答

立即登入回答