2016-04-20 156 views
0

我下面一個在線教程創建一個小型購物車,一切都進展順利,但現在我得到這個錯誤:致命錯誤:未捕獲的錯誤:調用未定義功能的mysql_query()

Fatal error: Uncaught Error: Call to undefined function mysql_query()

我不能在此錯誤的任何地方找到任何信息。每次我谷歌,解決方案:

Fatal error: Uncaught Error: Call to undefined function mysql_connect()

出現。

PHP

$id = substr($prod_name, 14, (strlen($prod_name) - 14)); 
$get_query = mysql_query('SELECT Product_Id,Product_Name,Product_Price FROM Product WHERE Product_Id =' . mysql_real_escape_string((int) $id)); 
while ($get_row = mysql_fetch_assoc($get_query)) { 
//subtotal 
$sub = $get_row['Product_Price'] * $value; 
echo $value . ' x ' . $get_row['Product_Name'] . ' @ ' . $get_row['Product_Price'] . ' ' . $sub . '<br/>'; 
      } 

是使用的mysql_query一個壞主意?哪裏可能有我/教程出錯?任何幫助將非常有幫助

+3

'mysql_ *'函數已在PHP 7中刪除,請使用'mysqli_ *'而不是 – Panda

+1

http://stackoverflow.com/questions/13201095/call-to-undefined-function-mysql-query –

+1

應該對'mysql_connect'失敗,因爲在運行查詢之前需要建立連接。 'mysql_ *'函數是一個壞主意,因爲它們一直被棄用,並且有更好的選擇,比如PDO。 – skrilled

回答

2

如果您使用的PHP 7 mysql_ *功能從PHP7永久刪除。您可以檢查數據庫操作的PDO或mysqli。

+0

現在,因爲我使用PHP 7 – Monroe

相關問題