php - MySQL: Check if row exists does not really work -


i have encountered genuine problem cause uknown me. inserting datetime database (and other data). script works, adding new records , it's swell. genuine problem duplicating data. though have if-condition, not work :x

$data = $year."-".$month."-".$day." ".$godzina.":".$minuta;  $result = mysql_query("select * kolejka data '$data%'"); $exists = (mysql_num_rows($result))?true:false; if($exists){     header('location: location');     $_session['msg'] = 'text'; }else{  $sql = "insert kolejka (pid, mid, data, odbyta) values ('$id', '$mid', '$data', '0')"; } if (!mysql_query($sql)){     header('location: 'location');     $_session['msg'] = 'error'; } 

here's db:

db

it's got done mysql_query :> in advance comments

your problem concatenating values that, you're not padding numbers, don't match. ( 9:00 != 09:00) want create valid date format variables mktime():

 $data = date('y-m-d h:i', mktime ($godzina, $minuta, 0, $month, $day, $year)); 

Comments