0

Here is my php and mysql code. It don't show any data . please tell me where is my error:

   <?php
    $ddaa = mysql_query("SELECT ref FROM users WHERE id='$uid'");
    $mallu2 = mysql_query("SELECT mallu FROM users WHERE id='$ddaa'");
    $result = mysql_fetch_array($mallu2);
    echo $result['mallu'];
    ?>

1 Answers1

0

You can use Mysqli,mysql is deprecated a little example:

conection to db test

$mysqli = new mysqli('127.0.0.1', 'user', 'password', 'test');
if ($mysqli->connect_errno) {
 echo "Error: Errot on connection : \n";
    echo "Errno: " . $mysqli->connect_errno . "\n";
}

// the query

$sql = "SELECT ref FROM users WHERE id=$uid";

//if don't have result

if ($resultado->num_rows === 0) {
    echo "we can't find data with  $uid. try again !.";
    exit;
}

//print the result

while ($dato = $resultado->fetch_assoc()) {
echo $dato['ref'];
}

Mysqli Php documentation

Diego Avila
  • 700
  • 7
  • 24