I've got a simple PHP page with a list of events that are taking place at certain times on certain days, and this is my code:
<?
//connect to mysql
//change user and password to your mySQL name and password
mysql_connect("localhost","root","PASSWORD");
//select which database you want to edit
mysql_select_db("events");
//select the table
$result = mysql_query("select * from weekevent order by eventdate LIMIT 20");
//grab all the content
while($r=mysql_fetch_array($result));
{
//the format is $variable = $r["nameofmysqlcolumn"];
//modify these to match your mysql table columns
$event=$r["event"];
$eventdate=$r["eventdate"];
echo "<tr><td><b>$event</b></td><td>showing on $eventdate</td>";
}
// assumes that you have connected successfully to your database using mysql_connect and mysql_select_db
$result = mysql_query("select eventdate from events"); // runs a query in your database
if($result)
{
$row = mysql_fetch_assoc($result); // gets the first result set row from the database for the query
$databaseDate = $row["eventdate"]; // that is, reference the column name of your table
$formattedDate = date("Y-m-d G:i:s", strtotime($databaseDate)); // this puts the date into the format "yyyy-mm-dd h24:mm:ss"
}
?>
yet I get this error:
Notice: Undefined variable: formattedDate in C:\www\vhosts\eventsweb\eventsweekly.php on line 20
What should I do so it shows events properly?