[請益] function中是否不能使用mysql_select_db和mysql_query呢?

看板PHP作者 (我的生命因你而發光)時間16年前 (2009/08/24 14:51), 編輯推噓1(102)
留言3則, 2人參與, 最新討論串1/1
function中是否不能使用mysql_select_db和mysql_query呢? 我是想說改變function的參數,然後在去資料庫中抓取相關資料出來 不知道有怎樣解法嗎? 錯誤訊息 Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in C:\myPage\relation\count.php on line 40 Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in C:\myPage\relation\count.php on line 42 ====程式內容=== function children_money($colname_cot,$mony,$level=1){ mysql_select_db($database_relation_conn, $relation_conn); $query_cot = sprintf("SELECT * FROM relatiion WHERE mid = %s", GetSQLValueString($colname_cot, "text")); $cot = mysql_query($query_cot, $relation_conn) or die(mysql_error()); $row_cot = mysql_fetch_assoc($cot); $totalRows_cot = mysql_num_rows($cot); $row_cot['money']=$row_cot['money']*(1+$per[$level]); $deleteSQL = sprintf("UPDATE relatiion SET money=". $row_cot['money'] . " WHERE mid = %s", GetSQLValueString($colname_cot, "text")); $Result33 = mysql_query($deleteSQL, $adivic_conn) or die(mysql_error()); if(is_null($row_cot['parent'])){ break;}else{ children_money($row_cot['parent'],$mony,$level+1); } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 60.245.105.138

08/24 14:53, , 1F
應該是function裡沒有$relation_conn吧!
08/24 14:53, 1F

08/24 19:16, , 2F
如果只有一個db連線的話 不如不要寫
08/24 19:16, 2F

09/15 00:45, , 3F
要不要轉CodeJob?
09/15 00:45, 3F
文章代碼(AID): #1AaZY7l5 (PHP)
文章代碼(AID): #1AaZY7l5 (PHP)