mysql - WebMatrix PHP Query Not working -
just heads have been writing php 3 days. having trouble query. when run query in query tool finds looking for. have tried every variation of syntax can think of using (how right now) , = , cannot work. sure there simpler way rest of code main concern right query. help.
$incident_d = $_post['incident_d']; $incident_d = strtotime($incident_d); $incident_t = $_post['incident_t']; $incident_t = strtotime($incident_t); $incident_t = ($incident_t % 86400); $incident_dt = $incident_d + $incident_t; $sql = "select dept.department department dept inner join near_miss nm on dept.dept_index = nm.dept_index nm.incident_dt '%" . $incident_dt . "%'"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { $result1 = $row['department']; } } else { $result1 = "no response"; } $result = $result1;
if manually type in value $incident_dt able find it. why think problem in how value being stored in $incident_dt. when echo value variable , paste query tool works.
$sql = "select dept.department `department` dept inner join near_miss nm on dept.dept_index = nm.dept_index nm.incident_dt '%" . $incident_dt . "%'";
the tick necessary php on tablename.
Comments
Post a Comment