PHP/MYSQL problem with some time thrown in!

Associate
Joined
13 Jan 2007
Posts
2,424
Location
Belfast,Northern Ireland
Here is the whole thing:

http://pastebin.com/LNXXASL6

It's only concerned with the submit section for now. Basically I want to check for conflicts between assigning shows for certain times. Here is my attempt:

Code:
$sql = "SELECT * FROM schedule WHERE starttime>='$starttime' AND endtime<='$endtime' AND day='$updateday'";
						$result = mysqli_query($myconnection, $sql);
						// Mysql_num_row is counting table row
						$count = mysqli_num_rows($result);						
										
							if($count >=1)
							{
								$error_msg = '<font color="#FF0000">*A show is already scheduled during that time slot.</font>';
							}
							else
							{

Frankly it isn't doing anything. I know the logic isnt spot on as it should only work for times inside other scheduled shows but this will do for now. The database uses TIME to store the starttime and endtime values. I collect the values from a user entry form like so:

Code:
$starttime = mysqli_real_escape_string($myconnection,$_POST['starttime']);
	$endtime = mysqli_real_escape_string($myconnection,$_POST['endtime']);
	
	$starttime = date($starttime, $timestamp);
	$endtime = date($endtime, $timestamp);

Should these not both be in the same format now? Can anyone tell me why this isn't working :( ?
 
Last edited:
On submit the times are in the format 11:30, 11:45 - in the DB they are 11:30, 11:45 - is this enough to make a difference? I didn't think it would be.

Using unix_timestamp doesnt change anything

*Yup it isn't enough to make a difference, worked once and thought it was sorted but appears not. Entering values as 11:00:00 etc now but no change
 
Last edited:
nevermind was being a tard but getting some really old behaviour from my code :/
 
spoke too soon, my conditional statement was wrong. However im sure my logic is spot on now yet its always messing up. Currently lets a user enter anything they want:

http://pastebin.com/M2sw2VeX

before that i was doing a count using mysqli_num_rows, each time it hit an error despite entering valid times.

Literally on the verge of suicide..
 
solved, dear lord that was grim.

Warning for all, do not use brackets in BETWEEN statements
 
Back
Top Bottom