[請益] 字串錯誤?

看板PHP作者 (阿電)時間12年前 (2012/03/27 15:49), 編輯推噓1(1011)
留言12則, 7人參與, 最新討論串1/1
如題 我的網頁一直出現下列文字! Parse error: syntax error, unexpected T_VARIABLE in /home/a6450262/public_html /nhush_sys/student_election/write.php on line 5 可是我檢查老半天,都沒發現有什麼問題ㄚ! 程式碼: <?php $_POST[no]==$no $fread=fopen("data/count/.$no..txt","r+"); $read=fgets($fread); fclose($fread); $total=$read + $_POST['add']; $fwrite=fopen("data/count/".$no.".txt","w+"); fputs("$fwrite","$total"); fclose($fwrite); echo("<script>document.location.href="management.php"</script>"); ?> 請哪位專家幫忙解答....Please!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.21.202.123

03/27 15:50, , 1F
沒分號
03/27 15:50, 1F

03/27 16:03, , 2F
第2行沒分號, 第4行也怪怪的, 第15行沒有加脫逸字元, 不然就
03/27 16:03, 2F

03/27 16:03, , 3F
改成 '
03/27 16:03, 3F

03/27 16:07, , 4F
第一行 $_POST[no]==$no 就有問題了..... 這行你想幹什麼?
03/27 16:07, 4F

03/27 23:54, , 5F
第二行沒出現時就有這個問題了
03/27 23:54, 5F

03/27 23:55, , 6F
另外這是一個寫入檔案的程式,檔名從外部表單傳入
03/27 23:55, 6F

03/28 00:10, , 7F
根據error很明顯的是變數餵進去時有問題
03/28 00:10, 7F

03/28 00:11, , 8F
你後面 fopen 寫對,第五行的 fopen 卻錯了
03/28 00:11, 8F

03/28 01:17, , 9F
用了雙引號就不要多此一舉用 . 連接字串
03/28 01:17, 9F

03/28 01:18, , 10F
'data/count/'.$no.'.txt',或"data/count/{$no}.txt"
03/28 01:18, 10F

03/28 01:23, , 11F
已經降低效率就不要再降低readibility,不然就改單引號.
03/28 01:23, 11F

03/28 10:26, , 12F
#1F3Ei9lx 想起前陣子的這個東西
03/28 10:26, 12F
文章代碼(AID): #1FSN4OMK (PHP)