0

This is my code:

<!DOCTYPE html>
<html>
<body>
<?php
$servername = "localhost";
$username = "alasgsco_user";
$password = "pass123";
$dbname = "alasgsco_alasdb";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
$sql = "SELECT 'ime' FROM 'kafici'";
$result = mysql_query($query);

while($row = mysql_fetch_array($result)){
echo "<p>" . $row['ime'] . "<br />";
}
$conn->close();
?>  
</body>
</html>

'kafici' is the name of the table 'ime' is the name of a column Why isn't my code working? Someone please help me! Thank you in advance.

  • You're mixing `mysql` and `mysqli` APIs. – Rajdeep Paul May 09 '16 at 17:34
  • 1
    Nobody reads the "Fabulous" manuals anymore? Or they feel that deviating from one will work with another? I sincerely doubt that. Btw, that isn't like a *ham & cheese sandwich* ;-) – Funk Forty Niner May 09 '16 at 17:36
  • Also don't use `mysql_*` functions, they are deprecated as of PHP 5.5 and are removed altogether in PHP 7.0. Use [`mysqli`](http://php.net/manual/en/book.mysqli.php) or [`pdo`](http://php.net/manual/en/book.pdo.php) instead. [And this is why you shouldn't use `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). – Rajdeep Paul May 09 '16 at 17:39

0 Answers0