Jump to content

msql database php help


cchar
Go to solution Solved by maxxd,

Recommended Posts

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 ";
}
?>
Link to comment
Share on other sites

  • Solution

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 by maxxd
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.