Jump to content
delk1ch

Output from database not working

Recommended Posts

Hello,

I'm trying to output my database on my website but it's not working, it shows up just a blank page ( http://prntscr.com/90dfbf ), here's the code :

<html>
  <head>
    <title>Untitled</title>
  </head>
  <body>
<?php

require_once(‘conn.php’);

$sql = ("SELECT * FROM oglasi");

$query = mysql_query($sql);

while ($row = mysql_fetch_array($query)) {

$naziv = $row[‘naziv’];
$sadrzaj = $row[‘sadrzaj’];

echo $naziv;

echo $sadrzaj;

};

?>
  </body>
</html>

And conn.php is:

<?php

$conn = mysql_connect(‘localhost’, ‘root’, ‘ELsk0l@r00t’)
or die (mysql_error());

mysql_select_db(‘elskoglasi’)
or die (‘Database selection incorrect’);

?>

Share this post


Link to post
Share on other sites

Instead of actual single quotes, you have some kind of fancy quotes:

‘ should be '

So you'll need to fix your editor.

 

You also need to turn the error messages back on so that PHP will tell you what's wrong:

Last but not least, the mysql_* functions are hopelessly outdated and will be removed in PHP 7 (which is released in a few days). Nowadays, we use PDO.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.