WebMatrix PHP Query Not working

Just a heads up I have been writing PHP now for about 3 days. I am having trouble with a query. When I run the query in the query tool it finds exactly what I am looking for. I have tried every variation of syntax I can think of from using LIKE (how it is right now) and = and i cannot get it to work. I am sure there is a simpler way to do the rest of the code but my main concern right now is the query. Thanks for all the 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 From department dept inner join near_miss NM on dept.Dept_Index = NM.Dept_Index Where NM.Incident_DT LIKE '%" . $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 i manually type in the value for $Incident_DT it is able to find it. This is why I think the problem is in how the value is being stored in $Incident_DT. also when I echo the value for the variable and paste it into the query tool it works.

-------------Problems Reply------------

$sql = "SELECT dept.Department From `department` dept inner join near_miss NM on dept.Dept_Index = NM.Dept_Index Where NM.Incident_DT LIKE '%" . $Incident_DT . "%'";

The back tick is necessary for PHP on the TABLENAME.

Try this:

declare a new variable with value:



$sql = "SELECT dept.Department From department dept inner join near_miss NM
on dept.Dept_Index = NM.Dept_Index Where NM.Incident_DT LIKE '$filter_var'";

Category:php Views:4 Time:2018-12-04

Related post

  • PHP Query not working 2011-06-12

    I have a problem that is staring me in the face but I cannot seem to solve it. First of: 1) the code is parsed prior to check for SQL injection. 2) $dbc is a reference that is part of another script that is "require_once()" called in and is working p

  • PHP query not working as it should 2011-10-30

    I am doing a small project, and came up with a problem. I want to print all tags given by a single user, that user name is inserted in an HTML, however it's not printing anything. I know I previously inserted all data in the db correctly. <?php in

  • Simple wordpress database php query not working 2011-10-13

    I'm using this code here: <?php $post_id = 3651; $queried_post = get_post($post_id); $title = $queried_post->post_title; echo $title; echo $queried_post->post_content; ?> post id 3651 definitely exists, but I keep getting a server error.

  • update query not working in cake php 2012-04-09

    data is coming this form Array ( [User] => Array ( [first_name] => sxsaxs [last_name] => sdsdsd [contact_no] => 9569908024 [address_1] => sdasd [address_2] => dsdsdsd [country_id] => 1 [state_id] => 1 [city_id] => 1 ) ) use

  • mysql insert sub query not working 2011-12-17

    Please see my query, insert into wp_9m8phu_term_relationships as rel (object_id,term_taxonomy_id,term_order) values ( 'select object_id+1 as object_id from wp_9m8phu_term_relationships where object_id!='' order by object_id desc limit 0,1', '".$fnds_

  • PHP $_POST not working? 2012-01-25

    This question already has an answer here: PHP POST not working 3 answers I have the simplest form possible and all I want to do is echo whatever is written in text box. HTML: <form action="" method="post"> <input type="text" name="firstname"

  • PHP Sockets Not Working 2010-06-18

    I switched from Lighttpd server to WAMP and then found sockets in php are not working. But php is configured and working. (phpinfo() works) I removed the comment for the php_sockets.dll in php.ini @ C:\wamp\bin\php\php5.2.5.but still gives the error

  • Media query not working in IE9 2011-06-20

    I'm having a strange problem that only occurs with IE9. I'm working on a web page that has a desktop layout, and a mobile layout. Same HTML, different CSS. The problem happens with the code below: @media only screen and (min-device-width: 768px) and

  • SQL Server: why does this Delete query not work? 2011-11-09

    I have 2 tables FinalList and RemoveTheseIDsList. They both have the same primary key of ID. I want to remove all rows from FinalList that are in RemoveTheseIDsList. So, I wrote this first query: Delete from FinalList Where FinalList.ID not in (Selec

  • update query not working in sqlite 2011-12-03

    my problem is unable to update data because of special character single quote (') in sq-lite database. i want update data but special character(') single quote in string give error into sq-lite database in android how to update. The Query is : update

  • SQLite query not working - (Objective-c) 2012-05-02

    I'm using xCode 4.3.2. Here I'm trying to load Column Names and Values from the database. When i use sqlQuery: "select * from mytable Where company like 'SONY'", its not working, but "select * from mytable" is woking fine. Could you please help me? s

  • Multiple query on PHP dows not work 2011-07-25

    Consider this simple PHP page: <?php $db = new mysqli("localhost", "myuser", "mypwd", "mydb"); if ($db->connect_error) // Dying sequence; // Executing query $qres = $db->multi_query("SET @rank = -1; SELECT * FROM (SELECT @rank := @rank + 1 a

  • PHP PDO AJAX Query not working, my eyes are crossing 2012-01-09

    I am re-writing a file that will dynamically build queries to search and match any word in an string passed by an ajax event... I cannot get the thing to return data. It acts like everything worked perfectly, but it didn't. All I get in firebug is su

  • mysql query not working in php? 2013-11-10

    My mysql table has 6 fields bkid bkname bkauth bkpub bkedn bkstock. This program is just for testing you may see some extra lines which I have commented out because I am not using the commented lines for now. Just for now I am trying to get bkid from

  • Phonegap - PHP Update Query Not Working on Emulator 2014-09-19

    I am developing phonegap dynamic application with php, for that I put dynamic (php) files on server, but my issue is that when I run application in browser, Its working fine, but when I run that on emulator, its work first time (Not all time, some ti

  • PHP eval() code returned from mysql query *not working* 2011-10-18

    if i take and do something like this: $p = 10; $n = 3; $evalstr = "\$f = 0.99 + ((.025 * \$p) * \$n);"; eval($evalstr); echo $f; I get 1.74 displayed, no errors everything is fine, but when I have a mysql table that holds these equations (for the pur

  • PHP - mysql query not working when using NOT LIKE 2012-03-01

    I have a query string being built and it works fine when I use LIKE but it will not work with NOT LIKE $sWhere = ""; if ( $_GET['sSearch'] != "" ) { $aWords = preg_split('/\s+/', $_GET['sSearch']); $sWhere = "WHERE ("; for ( $j=0 ; $j<count($aWord

  • Access query not working? 2009-09-14

    I remember using a query like this which worked for me before. But now its giving me a compile error. I am trying to get only the first 3 characters of the second field. select field1, left(field2, 3) from table1; What am I doing wrong? -------------

  • php mysql_insert_id(); not working 2009-12-14

    Hi guys I was hoping from some help here, please. I have a INSERT query to a table, after this is done I am calling: mysql_insert_id(); In order to send the last ID inserted into the table to the next page like this: $insertGoTo = "confirm_booking.ph

  • Why is this SQL query not working? 2010-02-05

    this script have to update things on every refresh but not working. lend me a hand $yp = mysql_query("select id from yyy where twitterid = '$tid'"); $qq = "update yyy set twitterid = '$tid', twitterkullanici = '$twk', tweetsayisi = '$tws', takipettig

  • Join Query Not Working 2010-05-31

    I am using three MySQl tables: comment commentid loginid submissionid comment datecommented login loginid username password email actcode disabled activated created points submission submissionid loginid title url displayurl datesubmitted In these th

  • Mysql resource into PHP array not working 2010-08-12

    I have posted this yesterday, I didn't get the the answers that could solve my problem but I got some pretty good ideas anyhow. This code retrieves the associated row from the db and translates it into PHP array so I could display it as a profile inf

  • Simple query not working 2010-10-25

    The simple query below is not returning any results. I can't see any errors in it. Any idea why it's not working? $sqlStr3 = "SELECT loginid, username, created FROM login ORDER BY created DESC LIMIT 200"; $result = mysql_query($sqlStr3); $count = 1;

  • Calling javascript function with php code - Not working 2010-12-02

    I am trying to call the Javascript function declared at the top in my php area. However its not working. Can anyone tell me the reason for it. Everything else is working except for this part. Please help me. <!doctype HTML PUBLIC "-//W3C//DTD HTML

  • Why is this Xpath Query not working on the DOM of facebook application pages? 2011-03-02

    I dont understand why my xpath query returns the correct href for the second url but not the first url. The HTML code looks the same. It contains the same kind of structure. But somehow no href is returned. (I just comment out each one of the $url's

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.165 (s). 11 q(s)