Jump to content

Selecting Todays Date From Database


Tenaciousmug

Recommended Posts

Here is my select statement:

$sql = "SELECT date FROM sixdice WHERE username='$username'";

 

I'm trying to select the date from the game I'm creating to see if that user already rolled the dice today.

 

Ok this is what I have:

 

<?php
include("haha.php");
$cxn = mysqli_connect($dbhost,$dbuser,$dbpassword,$dbdatabase);
$sql = "SELECT date FROM sixdice WHERE username='$username'";
$result = mysqli_query($cxn,$sql) or die("Couldnt find username");
$row = mysqli_fetch_array($result);
if($row['date'] == now());
{
echo "<br><br><form action='sixdice.php?roll' method='post'>
<input type='submit' name='continuesix' value='Continue Game' />
</form>";
}else
{
echo "<br><br><form action='sixdice.php?roll' method='post'>
<input type='submit' name='playsix' value='Play!' />
</form>";
}?>

 

It's giving me this error:

"

Parse error: syntax error, unexpected T_ELSE in /home2/asterock/public_html/sixdice.php on line 25"

Which is this line:

}else

 

 

 

EDIT

Also, doesn't the now() function select the time as well? I only want to select today's DATE. Not the time too.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.