kuttan939 Posted July 14, 2008 Share Posted July 14, 2008 Hi I am new to PHP. I am in a new project to integrate google map. I need to generate an XML file from MSSQL database. I have written a PHP code as below, but it is not working..... <?php $myServer = "192.168.0.26"; $myUser = "sa"; $myPass = ""; $myDB = "tavi"; //create an instance of the ADO connection object $conn = new COM ("ADODB.Connection") or die("Cannot start ADO"); //define connection string, specify database driver $connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB; $conn->open($connStr); //Open the connection to the database //declare the SQL statement that will query the database $query = "SELECT TimeStamp,X,Y FROM tavi.Message"; //execute the SQL statement and return records $rs = $conn->execute($query); $num_columns = $rs->Fields->Count(); //echo $num_columns . "<br>"; for ($i=0; $i < $num_columns; $i++) { $rows[$i] = $rs->Fields($i); } echo "<table>"; while (!$rs->EOF) { echo "<tr>"; echo "<?xml version='1.0' encoding='UTF-8'?><markers><marker lat='". $rows[$i]['lat']."' lng='". $rows[$i]['lng']."' /marker></markers>"; echo "</tr>"; $rs->MoveNext(); //move on to the next record } echo "</table>"; //close the connection and recordset objects freeing up resources $rs->Close(); $conn->Close(); $rs = null; $conn = null; ?> Someone please help Thanks in advance Kuttan Quote Link to comment https://forums.phpfreaks.com/topic/114620-help-needed-generate-xml-from-mssql/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.