无法从数据库PHP获取数据

时间:2015-03-02 19:31:11

标签: php mysql

我创建了一个从数据库中获取数据的函数,但是它不起作用我不知道错误是什么 这是代码:

    <?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");
?>

1 个答案:

答案 0 :(得分:1)

而不是

echo Connect_Show("localhost","root","root","learn","users");

请使用:

Connect_Show("localhost","root","root","learn","users");

Connect_Show is a function, with echo commands in it, its not returning anything.