-2
我創建了一個函數從數據庫中獲取數據的數據,但它不工作,我不知道什麼是錯 這裏是代碼:無法從數據庫PHP
<?php
function Connect_Show($server_name,$server_user,$server_pass,$db,$db_table){
$connect = mysql_connect($server_name,$server_user,$server_pass) or die ('error , can not connect to database ') ;
$select = mysql_Select_db($db) or die (' error , can not select the database ');
$query = mysql_query("SELECT * FROM $db_table order by id ")
while ($rows = mysql_fetch_assoc($query)) {
echo $rows['id'];
echo $rows['name'];
echo $rows['emails'];
echo $rows['password'];
}}
echo Connect_Show("localhost","root","root","learn","users");
?>
什麼是錯的是不好的縮進,壞資本和不好用廢棄的'mysql_'代替'mysqli_'或PDO。 – developerwjk 2015-03-02 19:40:13
並缺少分號。並且在一些呼叫之後不檢查錯誤。 – 2015-03-03 02:25:44