php - Why is sqlsrv_fetch_array() returning null? -


i trying make simple query sql database using php, no matter do, seems can't pull proper results. following code have written:

$lodate = '2013-10-01'; $hidate = '2015-01-01'; $querystr = "select timecol dbo.subpump timecol between " . $lodate . " , " . $hidate; $conn = sqlsrv_connect($servername, $coninfo); $result = sqlsrv_query($conn, $querystr);  while ($row = sqlsrv_fetch_array($result)) {     // never prints.     echo "row:<br>"; var_dump($row); echo "<br><br>"; }  echo "<br><br><br>";  // prints "coninfo: resource(2) of type (sql server connection)" echo "conn: "; var_dump($conn); echo "<br><br>";  // prints "result: resource(3) of type (sql server statement)" echo "result: "; var_dump($result); echo "<br><br>";  // prints "row: null" echo "row: "; var_dump($row); echo "<br><br>"; 

what confused on how can establish proper connection database.

since $conn , $result not print errors, yet not seem fetch data me.

so far, best guess since attempting grab data database through vpn, , might have tenuous connection, sqlsrv_connect() attempt try many times connect database until receives single connection. while sqlsrv_query() attempt once, , fails gather data.

does else have ideas might going wrong here?

even result equal null, $result returns this

// prints "result: resource(.) of type (sql server statement)" echo "result: "; var_dump($result); echo "<br><br>"; 

your query may returns null, because of date format. did try query without dates

$querystr = "select timecol dbo.subpump";


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -