Page 1 of 1

php/mysql query problem

Posted: Mon Jan 24, 2011 3:52 pm
by someguyhere
In the code below, I get a null value. If I echo $month_start and $upcoming_events_end, I get 2011-01-01 and 2011-01-31, so it appears that the correct data is being passed. Any idea what might be wrong here?

Code: Select all

			$month_start = date('Y') . '-' . date('m') . '-01';
			$query = "SELECT * FROM wp_calendar WHERE event_category = '4' BETWEEN '$month_start' AND '$upcoming_events_end'";
			$result = mysqli_query($mysqli, $query) or die(mysqli_error());
			$cal_banner = mysqli_fetch_row($result);

Re: php/mysql querry problem

Posted: Mon Jan 24, 2011 3:55 pm
by John Cartwright
Check mysqli_num_rows($result) to see if the query returned any results.

What happens if you run the query directly through mysql or phpmyadmin? Do you get rows returned?

Re: php/mysql query problem

Posted: Mon Jan 24, 2011 5:05 pm
by AbraCadaver
$query = "SELECT * FROM wp_calendar WHERE event_category = '4' AND something BETWEEN '$month_start' AND '$upcoming_events_end'";

Re: php/mysql query problem

Posted: Mon Jan 24, 2011 5:26 pm
by someguyhere
Thanks - that helped me find my problem :)