jeudi 7 juillet 2016

PHP SQL Statement dont work

whats wrong with my code? I get the SQL Error output. If I enter the SQL Statement in PHPMYADMIN it works fine. Could you helf me guys?

    <html>
<body>
<?php
require_once ('connection.php');
$db_link = mysqli_connect (
    MYSQL_HOST,
    MYSQL_USER,
    MYSQL_PW,
    MYSQL_DB
);

$sql ="SELECT ip, username, password from table WHERE available = 1 LIMIT 1" ;
if ($result = $db_link->query($sql) ) {
    echo "<p>Your login details:  </p><table>";
    while ($row = $result->fetch_array() ) {
        echo "<tr>";
        echo "<td>", "$row[0]","</td>";
        echo "<td>", "$row[1]","</td>";
        echo "</tr>";
    }
    echo "</table>";
    $result->close();
}
else {
    echo "SQL Error";
}
$db_link->close();
?>
</body>
</html>

Aucun commentaire:

Enregistrer un commentaire