Re: [請益] 小問題

看板PHP作者 (小小世界)時間18年前 (2007/07/31 14:35), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串3/9 (看更多)
※ 引述《showsky (小小世界)》之銘言: : ※ 引述《Chouje (~~哇是卡倉~~)》之銘言: : : 今天在做與資料庫連結的小綀習時~程式碼如下: : : ------------------------------------------------------------------------------ : : <html> : : <body> : : <?php : : if (isset($old_name)){ : : $link_ID = mysql_connect("localhost:3306","root"); : 預設PORT就是3306 不需要麻煩這樣寫 : : mysql_select_db("bc_book"); : : $str = "select * from customers where name='$old_name';"; : SQL語法錯誤 去掉分號select * from customers where name='$old_name' $str = "select * from `customers` where `name`='$old_name'"; : : $result = mysql_query($str,$link_ID); : : mysql_close($link_ID); : : $record = mysql_fetch_row($result); : : } : : ?> : : 請在下面輸入資料後查詢: : : <form action="a.php" method="POST"> : : 姓名:<input type="text" name="old_name"> : : <input type="submit" value="查詢!"> : : </form> : : <?php : : if (isset($record)){ : : if($record){ : : echo"姓名:".$record[1]; : : echo"職業:".$record[2];} : : else{echo "查無此人!!";} : : } : : ?> : : </body> : : </html> : : 這個時後用網頁跑出來時他寫了: : : Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result : : resource : : 這樣寫是表示我要怎麼修改呢??@@~~因為跑不出書上的結果~~>"< : : 是啥麼原因~剛學不久^^|||~~先謝謝回答的大大們~~^^ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.62.124.117
文章代碼(AID): #16hjX4O9 (PHP)
討論串 (同標題文章)
本文引述了以下文章的的內容:
2
6
以下文章回應了本文
0
2
完整討論串 (本文為第 3 之 9 篇):
1
11
2
4
4
10
3
4
0
2
2
6
2
2
文章代碼(AID): #16hjX4O9 (PHP)