Cyonis Posted January 15, 2014 Share Posted January 15, 2014 Hello all, This is my first post on this forums and I'm building a webpage using php for the first time, so excuse me if my question is a very simple one and easy to google... I just have no clue where to look. I'm using php to make a connection to my database, which seems to work, because creating tables works. The following code does nothing for some reason: $result = mysqli_query($con,"SELECT * FROM NEWS;"); while($row = mysqli_fetch_array($result)) { echo "<div class='news'>"; echo "<div class='author'>Author: " . $row['AUTHOR'] . "</div>"; echo "<div class='time'>" . $row['TIME'] . "</div>"; echo "<div class='post'>" . $row['NEWS'] . "</div>"; echo "</div>"; } My connection is stored into $con, which works, I have tried and I can create tables using $con. Thank you already for helping, it's much appreciated. Oh, I should add, I get no error messages at all, just no output. It works perfectly local, but as soon as I upload it, it breaks. Link to comment https://forums.phpfreaks.com/topic/285388-query-not-working/ Share on other sites More sharing options...
Barand Posted January 15, 2014 Share Posted January 15, 2014 Have you checked for an error? if (!$result) echo mysqli_error($con); Link to comment https://forums.phpfreaks.com/topic/285388-query-not-working/#findComment-1465323 Share on other sites More sharing options...
SalientAnimal Posted January 15, 2014 Share Posted January 15, 2014 Have you tried removing the ; at the end of your select query? So that it would be: $result = mysqli_query($con,"SELECT * FROM NEWS"); Link to comment https://forums.phpfreaks.com/topic/285388-query-not-working/#findComment-1465324 Share on other sites More sharing options...
Cyonis Posted January 15, 2014 Author Share Posted January 15, 2014 I got the following error: Table '[databasename].NEWS' doesn't exist. Well, I found the problem. Things aren't case senstive on my local server, but they are on my webserver. Link to comment https://forums.phpfreaks.com/topic/285388-query-not-working/#findComment-1465325 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.