Cyonis Posted January 15, 2014 Share Posted January 15, 2014 (edited) 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. Edited January 15, 2014 by Cyonis Quote Link to comment https://forums.phpfreaks.com/topic/285388-query-not-working/ Share on other sites More sharing options...
Solution Barand Posted January 15, 2014 Solution Share Posted January 15, 2014 Have you checked for an error? if (!$result) echo mysqli_error($con); Quote 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 (edited) Have you tried removing the ; at the end of your select query? So that it would be: $result = mysqli_query($con,"SELECT * FROM NEWS"); Edited January 15, 2014 by SalientAnimal Quote 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 (edited) 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. Edited January 15, 2014 by Cyonis Quote Link to comment https://forums.phpfreaks.com/topic/285388-query-not-working/#findComment-1465325 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.