[請益] 請幫看一下程式碼

看板PHP作者 (tanxdx)時間16年前 (2009/10/17 17:46), 編輯推噓8(8010)
留言18則, 3人參與, 最新討論串1/1
這是我的程式碼,我在appserv-win32-2.4.7可以正常執行,但是在WampServer2.0i執行 卻會出現Parse error: parse error in C:\wamp\www\xxx\xxx.php on line 101 請幫我看一下哪邊有問題 <?php $link = mysql_connect('localhost', 'root', ''); mysql_select_db("test", $link) or die("資料庫連結錯誤"); ?> <title>123</title> <html> <head> </head> <body> <form action="" method="post"> <center><select name="language"> <option>請選擇</option> <option value="l">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> </select> <INPUT TYPE="SUBMIT" VALUE="開始查詢"></center> </form> </div> <div class="style3"> <p> <?php if($language !=""){ $sql = "select * from $language where id like '%$id%'"; $id = 0; $result = mysql_query($sql) or die(mysql_error());; $row = mysql_fetch_row($result); ?> </p> <table width="1023" border="1"> <tr> <td>a</td> <td>b</td> <td>c</td> <td>d</td> <td>e</td> <td>f</td> <td>g</td> </tr> <? while ($row != NULL) { list( $id, $vocabulary, $chiexample, $rot, $example, $Translation, $Note) = $row; { echo "<td>$id</td>"; echo "<td>$vocabulary</td>"; echo "<td>$chiexample</td>"; echo "<td>$rot</td>"; echo "<td>$example</td>"; echo "<td>$Translation</td>"; echo "<td>$Note</td>"; echo "<td><a href=update.php?id=$id&language=$language target=_blank>修改資料</a></td>"; echo "<td><a href=del.php?id=$id&language=$language target=_blank onclick='return delconfirm()'>刪除此筆資料</a></td>"; echo "</tr>"; } $row = mysql_fetch_row($result); } } mysql_close($link); ?> </table> <p>&nbsp; </p> </body> </html> <script> function delconfirm(){ if(window.confirm("確定刪除資料?")) { location.reload(); return true; } else return false; } </script> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.33.77.10

10/17 19:28, , 1F
好像貼上來的也沒有101行,看起來list那邊有錯
10/17 19:28, 1F
嗯 我有改到 他都會在最後一行給我錯誤>< 那要怎麼修訂呢? ※ 編輯: tanxdx 來自: 114.33.77.78 (10/17 19:34)

10/17 20:19, , 2F
所以list那行到底是?
10/17 20:19, 2F
※ 編輯: tanxdx 來自: 114.33.77.78 (10/17 20:31)

10/17 20:56, , 3F
因為你說原來的環境可以執行,換一個環境無法執行,另外,
10/17 20:56, 3F

10/17 20:58, , 4F
while 前方的是 <? ,因此,我想會不會是short tags的問
10/17 20:58, 4F

10/17 20:58, , 5F
題!?
10/17 20:58, 5F
※ 編輯: tanxdx 來自: 114.33.77.78 (10/17 20:59) ※ 編輯: tanxdx 來自: 114.33.77.78 (10/17 21:37)

10/17 21:41, , 6F
如果我沒看錯的話 <? ?> 裡面有2個{ 3個}
10/17 21:41, 6F

10/17 21:58, , 7F
list( $id, $vocabula...後面接;跟{ 沒看過這種用法= =
10/17 21:58, 7F

10/17 22:00, , 8F
我也沒看過 不過可能{}值機被當成一個區塊跑而已
10/17 22:00, 8F

10/17 22:00, , 9F
直接..
10/17 22:00, 9F

10/17 22:01, , 10F
沒錯 {}是被當成一塊程式碼
10/17 22:01, 10F

10/17 22:01, , 11F
他已經被包在while的{}裡面了 所以沒有意義
10/17 22:01, 11F

10/17 22:02, , 12F
如果是short_tag的問題 code應該會直接吐出來
10/17 22:02, 12F

10/17 22:03, , 13F
應該是{}不對稱造成parse error
10/17 22:03, 13F

10/17 22:32, , 14F
我用搜尋的是3{3}
10/17 22:32, 14F

10/17 22:45, , 15F
剛剛測試了一下 的確是short_tag的問題 改成<?php即OK
10/17 22:45, 15F

10/18 00:51, , 16F
喔喔 有一個{是上面的if
10/18 00:51, 16F

10/18 00:51, , 17F
所以是short_tag沒開所以下面的}都不算數了
10/18 00:51, 17F

10/18 01:27, , 18F
是阿
10/18 01:27, 18F
文章代碼(AID): #1AsP9SJT (PHP)
文章代碼(AID): #1AsP9SJT (PHP)