還是mysql問題 我找不出來 高手看一下

來源:互聯網
上載者:User
function indeup($sql){
$c=mysql_connect("localhost","root","123456");
mysql_select_db("test");
if($result=mysql_query($sql,$c)){
return mysql_fetch_array($result);
}else{
return false;
}
}


echo indeup("insert into test_user (username,password) values('qqqqqq','qqqqqq')");

有警告錯誤 Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in D:\kisshc\apache\htdocs\mysql\index.php on line 15


回複討論(解決方案)

mysql_query() 僅對 SELECT,SHOW,EXPLAIN 或 DESCRIBE 語句返回一個資源標識符,如果查詢執行不正確則返回 FALSE
看看你的$sql是什麼語句

array mysql_fetch_array ( resource $result [, int $ result_type ] )
$result resource 型,是一個由mysql_query 產生的結果集

而你的sql是insert語句,mysql_query() 執行後只返回true或者false。

嗯謝謝你的回答 可是 return mysql_query($sql,$this->ID); 沒有返回的 true或false

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.