fx.barrett
10-10-2008, 04:12 PM
Hi guys,
I'm trying to format the data I'm reading form my DB and send it to Flash but I keep getting 2 errors:
PHP Warning: domdocument() expects parameter 2 to be long, string given in...
PHP Fatal error: Call to undefined function: createelement() in...
I'm still surfing the Net for answers but I thought that maybe someone can enlighten me much faster. By the way, my host has the following stuff:
Apache version 1.3.37 (Unix)
PHP version 4.4.6
MySQL version 4.1.22-standard
And this is the code I'm using to convert the data read from the DB.
I deleted the confidential stuff...
<?php
header("Cache-Control: no-store, no-cache, must-revalidate");
header("content-type: text/xml; charset=UTF-8");
$host = "";
$user = "";
$pass = "";
$db = "";
$table = "";
$xml = new DOMDocument("1.0", "UTF-8");
$root = $xml->createElement("news_root");
$root = $xml->appendChild($root);
$channelElement = $xml->createElement("channel");
$channelElement = $root->appendChild($channelElement);
$conn = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($db, $conn) or die("Could not find database.");
$query = "SELECT * FROM $table";
$result = mysql_query($query);
if ($result)
{
if (mysql_num_rows($result) > 0)
{
while ($row = mysql_fetch_array($result))
{
$newsDesc = $row['content'];
$itemElement = $xml->createElement('news_item');
$itemElement = $channelElement->appendChild($itemElement);
$itemDescriptionElement = $xml->createElement('description',$newsDesc);
$itemDescriptionElement = $itemElement->appendChild($itemDescriptionElement);
}
}
}
else
{
$messageElement = $xml->createElement('message',mysql_error());
$messageElement = $channelElement->appendChild($messageElement);
}
echo $xml->saveXML();
?>
I'm trying to format the data I'm reading form my DB and send it to Flash but I keep getting 2 errors:
PHP Warning: domdocument() expects parameter 2 to be long, string given in...
PHP Fatal error: Call to undefined function: createelement() in...
I'm still surfing the Net for answers but I thought that maybe someone can enlighten me much faster. By the way, my host has the following stuff:
Apache version 1.3.37 (Unix)
PHP version 4.4.6
MySQL version 4.1.22-standard
And this is the code I'm using to convert the data read from the DB.
I deleted the confidential stuff...
<?php
header("Cache-Control: no-store, no-cache, must-revalidate");
header("content-type: text/xml; charset=UTF-8");
$host = "";
$user = "";
$pass = "";
$db = "";
$table = "";
$xml = new DOMDocument("1.0", "UTF-8");
$root = $xml->createElement("news_root");
$root = $xml->appendChild($root);
$channelElement = $xml->createElement("channel");
$channelElement = $root->appendChild($channelElement);
$conn = mysql_connect($host, $user, $pass) or die("Could not connect to host.");
mysql_select_db($db, $conn) or die("Could not find database.");
$query = "SELECT * FROM $table";
$result = mysql_query($query);
if ($result)
{
if (mysql_num_rows($result) > 0)
{
while ($row = mysql_fetch_array($result))
{
$newsDesc = $row['content'];
$itemElement = $xml->createElement('news_item');
$itemElement = $channelElement->appendChild($itemElement);
$itemDescriptionElement = $xml->createElement('description',$newsDesc);
$itemDescriptionElement = $itemElement->appendChild($itemDescriptionElement);
}
}
}
else
{
$messageElement = $xml->createElement('message',mysql_error());
$messageElement = $channelElement->appendChild($messageElement);
}
echo $xml->saveXML();
?>