PHP - Access MS SQL View and Echo Results -


i'm trying access , read view ms sql database php. i'm trying echo out results on screen. when test, page shows nothing @ all. have:

<?php $myserver = "localhost"; $myuser = "username1"; $mypass = "password1"; $mydb = "database1";  //connect database $dbhandle = mssql_connect($myserver, $myuser, $mypass)   or die("couldn't connect sql server on $myserver");  //select database $selected = mssql_select_db($mydb, $dbhandle)   or die("couldn't open database $mydb");  //declare statement $query = "select productid"; $query .= "from inventory "; $query .= "where upc='15813658428' , manufacturerid=465";  //execute query $result = mssql_query($query);  $numrows = mssql_num_rows($result); echo "<h1>" . $numrows . " row" . ($numrows == 1 ? "" : "s") . " returned </h1>";  //display results while($row = mssql_fetch_array($result)) {   echo "<li>" . $row["id"] . $row["name"] . $row["year"] . "</li>"; } //close mssql_close($dbhandle); ?>  

often when blank output php, because server encountered problem when parsing or interpetting code. best way deal when getting no other errors strip out (or comment out) large blocks of code , use numeric echo statements verify code have not stripped out executing. add more , more of code in.

in specific case, guessing problem may come down spaces after ?> in php file. can confuse servers. try removing ?> completely.

if still results in no output, comment out after $mydb = "database1";, add echo statement right before commenting, , move code uncommented section until find line causes problem.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -