runnerjp Posted April 16, 2009 Share Posted April 16, 2009 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';} } ?> Quote Link to comment https://forums.phpfreaks.com/topic/154411-solved-wont-display-results-or-else-statement/ Share on other sites More sharing options...
Maq Posted April 16, 2009 Share Posted April 16, 2009 You need single quotes around $yes: $sql = "SELECT * FROM events WHERE date='$yes'"; If you put or die at the end of your query execution you would have seen this. Quote Link to comment https://forums.phpfreaks.com/topic/154411-solved-wont-display-results-or-else-statement/#findComment-811883 Share on other sites More sharing options...
The Little Guy Posted April 16, 2009 Share Posted April 16, 2009 Try this, it will echo out your $yes and a row (if the row exists) <?php include 'settings.php'; $yes=$_GET['month']; $sql = "SELECT * FROM events WHERE date='$yes'"; $postsresult = mysql_query($sql); $row = mysql_fetch_array($postsresult); echo $yes; echo '<br>'; echo $row['event']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/154411-solved-wont-display-results-or-else-statement/#findComment-811886 Share on other sites More sharing options...
soak Posted April 16, 2009 Share Posted April 16, 2009 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'"; Quote Link to comment https://forums.phpfreaks.com/topic/154411-solved-wont-display-results-or-else-statement/#findComment-811888 Share on other sites More sharing options...
runnerjp Posted April 16, 2009 Author Share Posted April 16, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/154411-solved-wont-display-results-or-else-statement/#findComment-811894 Share on other sites More sharing options...
runnerjp Posted April 16, 2009 Author Share Posted April 16, 2009 got it workin...thnaks guys Quote Link to comment https://forums.phpfreaks.com/topic/154411-solved-wont-display-results-or-else-statement/#findComment-811897 Share on other sites More sharing options...
The Little Guy Posted April 16, 2009 Share Posted April 16, 2009 include 'settings.php'; $yes=$_GET['month']; $sql = "SELECT * FROM events WHERE date='$yes'"; $postsresult = mysql_query($sql); echo 'Rows Found: '.mysql_num_rows($postsresult); Quote Link to comment https://forums.phpfreaks.com/topic/154411-solved-wont-display-results-or-else-statement/#findComment-811898 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.