Jump to content

[SOLVED] wont display results or else statement


runnerjp

Recommended Posts

i really cant figure out what im doing wrong here

in my db i have a time set as:04-15-2009...

 

my sql output is:SELECT * FROM events WHERE date=04-15-2009

 

but when i look on the page i get nothing

<?php
include 'settings.php'; 
$yes=$_GET['month'];

$sql = "SELECT * FROM events WHERE date=$yes";

$postsresult = mysql_query($sql);
// IF mysql_query() RETURNS FALSE, THERE IS DIAGNOSTIC INFORMATION AVAILBALE
$num = mysql_num_rows($postsresult);

while($row = mysql_fetch_assoc($postsresult)) {
if($num < 1)
    { 
echo $row['event'];}
else
{ echo 'no events';}
}
?>

Link to comment
Share on other sites

Your date is a string so needs to be in quotes. Whilst you're doing that at least put in a mysql_real_escape_string() as well:

 

<?php
include 'settings.php'; 
$yes=mysql_real_escape_string($_GET['month']);

$sql = "SELECT * FROM events WHERE date='$yes'";

Link to comment
Share on other sites

i put it in quotes and still nothin...

 

<?php
include 'settings.php'; 
$yes=$_GET['month'];

$sql = "SELECT * FROM events WHERE date='$yes'";
$postsresult = mysql_query($sql);


// IF mysql_query() RETURNS FALSE, THERE IS DIAGNOSTIC INFORMATION AVAILBALE
if (!postsresult)
{
   $errmsg = mysql_errno() . ' ' . mysql_error();
   echo "<br/>QUERY FAIL: ";
   echo "<br/>$sql <br/>";
   die($errmsg);
}
$row = mysql_fetch_array($postsresult);
echo $yes;
echo '<br>';
echo $row['event'];
?>

 

the output said nothin of errors :S

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.