note 87872 added to function.mssql-fetch-assoc

From: Date: Sun, 28 Dec 2008 10:35:45 +0000
Subject: note 87872 added to function.mssql-fetch-assoc
Groups: php.notes 
Request: Send a blank email to php-notes+get-148601@lists.php.net to get a copy of this message
With the code mentioned above and in relation to a MSSQL query. When using the following statements to retrieve dat "fetch_assoc" then running a split statement PHP it then into a array it will not pass the data retrieved will show correctly in a XML document created by the DOM object. <?php require("phpsqlajax_dbinfo.php"); // Start XML file, create parent node $dom = new DOMDocument("1.0"); $node = $dom->createElement("markers"); $parnode = $dom->appendChild($node); // Opens a connection to a DreameyeOne server $connection=mssql_connect ("ELF\ELF", $username, $password); if (!$connection) { die('Not connected : ' . mssql_error()); } // Set the active DreameyOne database $db_selected = mssql_select_db($database, $connection); if (!$db_selected) { die ('Can\'t use db : ' . mssql_error()); } // Select all the rows in the markers table $query = "SELECT msg FROM ozekimessagein ORDER BY senttime DESC"; $result = mssql_query($query); if (!$result) { die('Invalid query: ' . mssql_error()); } header("Content-type: text/xml"); // Iterate through the rows, adding XML nodes for each while ($row = @mssql_fetch_assoc($result)) { list ($vehicleID,$long,$lat) = split(',',$row); // ADD TO XML DOCUMENT NODE $node = $dom->createElement("marker"); $node = $dom->createElement("marker"); $newnode = $parnode->appendChild($node); $newnode->setAttribute("VehicleID:",$vehicleID); $newnode->setAttribute("lat",$lat); $newnode->setAttribute("long",$long); } echo $dom->saveXML(); ?> Merlinman ---- Server IP: 117.104.160.194 Probable Submitter: 58.171.133.172 ---- Manual Page -- http://www.php.net/manual/en/function.mssql-fetch-assoc.php Edit -- https://master.php.net/note/edit/87872 Del: integrated -- https://master.php.net/note/delete/87872/integrated Del: useless -- https://master.php.net/note/delete/87872/useless Del: bad code -- https://master.php.net/note/delete/87872/bad+code Del: spam -- https://master.php.net/note/delete/87872/spam Del: non-english -- https://master.php.net/note/delete/87872/non-english Del: in docs -- https://master.php.net/note/delete/87872/in+docs Del: other reasons-- https://master.php.net/note/delete/87872 Reject -- https://master.php.net/note/reject/87872 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148601) next »