Jump to content

Output from database not working

Recommended Posts


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 :



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

$query = mysql_query($sql);

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

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

echo $naziv;

echo $sadrzaj;



And conn.php is:


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

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.

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.