1

Trying to print values from table in mysql in php but it didn't show anything

$connect = mysql_connect("127.0.0.1","root","1234567");

$db = mysql_select_db("skynet");


    $query = mysql_query("SELECT * FROM users");
    while($rows = mysql_fetch_array($query)){
        $name  = $rows['$name'];
        $mail = $rows['$mail'];
            echo $name;
            echo $mail;
    }
Jonny C
  • 1,943
  • 3
  • 20
  • 36
  • 1
    Please, [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://jayblanchard.net/demystifying_php_pdo.html). Add error checking, such as `or die(mysql_error())` to your queries. You'll find the issues in your current error logs. – Jay Blanchard May 01 '15 at 15:33

1 Answers1

2

$name and $mail have no value and are being uses as the $row index, remove the $ for the $row[$xxx].

 $name  = $rows['$name'];
 $mail = $rows['$mail'];

remove the $ from inside the brackets for the $row[$xxx].

 $name  = $rows['name'];
 $mail = $rows['mail'];
Misunderstood
  • 5,534
  • 1
  • 18
  • 25