mysql - PHP with SQL Server - 500 Internal Server Error -
i working on project written in php , connecting mysql database part of masters class project, seemed have missed in scope using mssql database in our system.
i in process of going through files , adjusting queries etc in order work our database. in couple of places hitting wall 500 internal server error. in both cases, it's queries have variables in them, ie. search terms.
two examples of functions giving me error:
function callstores(){ $conn= databaseconnection(); $list= json_decode(stripslashes($_post['list'])); $storeslist="<br>"; if(count($list)==0) { echo "<br> no stores display x<br><br>"; //echo "calling no stores!"; } else { //echo "calling stores!"; foreach($list $d){ $sql = "select customerstoreid, customerid, storename, address1, town tblcustomerstores customerid= $d;"; $result = sqlsrv_query($conn,$sql, array(), array( "scrollable" => 'static' )); //if sql succeed if (sqlsrv_num_rows($result) > 0) { while($row = sqlsrv_fetch_array( $result, sqlsrv_fetch_numeric)) { $storeslist .= '<p id=""> <input type="checkbox" name="stores[]" value="'. $row["0"].'"> ' . $row["2"].' '. $row["3"].', '.$row["4"] .'</p>'; } } else { $storeslist .= "0 results"; } }//close loop echo $storeslist.'<br>'; } }
and second example
function searchcustomer(){ $conn= databaseconnection(); if(isset($_post['hint']) && ($_post['hint']!="")) { $hint =$_post['hint']; $sql = "select customerid, customername1, customername2 tblcustomers customername1 '".$hint."%' order customername1;"; } else { $sql = "select customerid, customername1, customername2 tblcustomers order customername1;"; } $result = sqlsrv_query($conn,$sql, array(), array( "scrollable" => 'static' )); ; //if sql succeed if (sqlsrv_num_rows($result) > 0) { while($row = sqlsrv_fetch_array( $result, sqlsrv_fetch_numeric)) { echo '<input type="checkbox" name="customers[]" onchange="changestoreslist()" value="'. $row["0"].'"> ' . $row["1"].' ' . $row["2"] .'<br>'; } } else { echo "0 results"; } sqlsrv_close( $conn); }
am correct in assumption in both cases it's search term causing problem, , if - correct approach it?
when check console, following: post http://localhost/includes/functions.php
500 internal server error 47ms
the "post" tabs shows: action showstores list ["4441"]
any suggestions appreciated!
Comments
Post a Comment