无法在Linux中使用php获取数据

I want to connect to a database and fetch data , But I can't do that . Would you mind helping me what is the problem ? By the way I use Linux Ubuntu. Here is the code and info :

<?php

// DB name : db
// Table name : users
// Columns : username , password
mysql_connect("localhost" "root" "root") or die(mysql_error());
mysql_select_db("db") or die(mysql_error());
$query = mysql_query("SELECT * FROM users") or die(mysql_error());
$fetch = mysql_fetch_array($query);
echo "Username :".$fetch['username'];
echo "Password :".$fetch['password'];
mysql_close();

?>

You forgot to seperate the variables on your mysql_connect statement. Do like this

mysql_connect("localhost", "root", "root") or die(mysql_error());
                   ------^  -----^   // Added commas here

EDIT :

Do like this..

while ($fetch = mysql_fetch_array($query, MYSQL_ASSOC)) {
    echo "Username :".$fetch['username'];
    echo "Password :".$fetch['password'];
}

Migrating to MySQLi from mysql_* , Read here


Most importantly, Stop using mysql_* functions as they are deprecated. Switch to MySQLi or PDO.