cchar Posted October 6, 2014 Share Posted October 6, 2014 I am trying to display items from my database that occur after the current date but within the next 28 days. I have wrote my script and the part that retrieves the information from the database works in phpmyadmin however when I load the page in the browser nothing below my php script is showing up on the page, where have I gone wrong? <?php //connect to the database include 'php/database_connection.php'; //retrieve all the information for the events within 28 days of the current date from the database $dateSQL = "SELECT eventID, eventTitle, eventDescription, eventStartDate, eventEndDate FROM te_events WHERE eventStartDate > CURRENT_DATE AND eventStartDate < CURRENT_DATE + INTERVAL 28 DAY ORDER BY eventStartDate"; //execute the query and store the results $queryDate = mysqli_query($dateSQL) or die(mysqli_error()); //loop through database and store in variables while ($row = mysqli_fetch_array($queryDate)) { $eID = $row['eventID']; $start = $row['eventStartDate']; $end = $row['eventEndDate']; $title = $row['eventTitle']; $desc = $row['eventDescription']; //echo events within the 4 week timeframe echo "<div class=\"date\">$start - $end</div> "; echo "<div class=\"title\"><a href=\"full_details.php?eventID=$eID\"></a></div> "; echo "<div class=\"desc\">$desc</div>\n "; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/291467-msql-database-php-help/ Share on other sites More sharing options...
Solution maxxd Posted October 6, 2014 Solution Share Posted October 6, 2014 (edited) Make sure you've got error reporting turned on: error_reporting(-1); ini_set('error_display',1); As to the actual cause of your error, it looks like you're trying to go from mysql_* to mysqli_* (which is good) by adding an 'i' to the end of the 'mysql' in the function calls and expecting it to work (which is bad - it won't). Check http://us2.php.net/manual/en/mysqli.query.php for information on how to use query(), and unless I'm mistaken there isn't a mysqli_fetch() function... Edited October 6, 2014 by maxxd Quote Link to comment https://forums.phpfreaks.com/topic/291467-msql-database-php-help/#findComment-1492854 Share on other sites More sharing options...
cchar Posted October 6, 2014 Author Share Posted October 6, 2014 so am I right in thinking instead of using mysqli_fetch I should use mysql_store_results? Quote Link to comment https://forums.phpfreaks.com/topic/291467-msql-database-php-help/#findComment-1492858 Share on other sites More sharing options...
Strider64 Posted October 6, 2014 Share Posted October 6, 2014 so am I right in thinking instead of using mysqli_fetch I should use mysql_store_results? No, you have to convert correctly over to mysqli, a simple way to convert would just go over to php.net and look at the examples -> http://php.net/manual/en/mysqli.construct.php Quote Link to comment https://forums.phpfreaks.com/topic/291467-msql-database-php-help/#findComment-1492859 Share on other sites More sharing options...
cchar Posted October 6, 2014 Author Share Posted October 6, 2014 Thank you for your help I have rewrote my connect to database script using mysqli now just for the rest. I must sound so thick right now Quote Link to comment https://forums.phpfreaks.com/topic/291467-msql-database-php-help/#findComment-1492882 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.