Hi every one. I'm trying to read a xml file dynamically from mysql database .
There is my actual code:
It only works if the file is a local file or if is an absolute path. Whenever i try to load the $PAD variable from a database is always return an error. Can you guys help me with this???
[code=php]
<?php require_once('. ./../Connections/xml.php'); ?>
<?php
if (!function_exis ts("GetSQLValue String")) {
function GetSQLValueStri ng($theValue, $theType, $theDefinedValu e = "", $theNotDefinedV alue = "")
{
$theValue = get_magic_quote s_gpc() ? stripslashes($t heValue) : $theValue;
$theValue = function_exists ("mysql_real_es cape_string") ? mysql_real_esca pe_string($theV alue) : mysql_escape_st ring($theValue) ;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValu e) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theV alue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValu e : $theNotDefinedV alue;
break;
}
return $theValue;
}
}
mysql_select_db ($database_xml, $xml);
$query_xmldat = "SELECT * FROM uno WHERE id = 1";
$xmldat = mysql_query($qu ery_xmldat, $xml) or die(mysql_error ());
$row_xmldat = mysql_fetch_ass oc($xmldat);
$totalRows_xmld at = mysql_num_rows( $xmldat);
// Includes
include_once(". ./include/padfile.php");
// Create PAD file object for the local file "pad_file.x ml"
// This could also be an absolute local path or an URL!
$PAD = new PADFile("./samples/pad_file.xml");
// Load file
if ( !$PAD->Load() )
echo "Error: Cannot load PAD file.<br>\n";
// Sample Output
echo "<b>Program Name:</b> " . $PAD->XML->GetValue("XML_ DIZ_INFO/Program_Info/Program_Name") . "<br>\n";
echo "<b>Program Version:</b> " . $PAD->XML->GetValue("XML_ DIZ_INFO/Program_Info/Program_Version ") . "<br>\n";
mysql_free_resu lt($xmldat);
?>
[/code]
There is my actual code:
It only works if the file is a local file or if is an absolute path. Whenever i try to load the $PAD variable from a database is always return an error. Can you guys help me with this???
[code=php]
<?php require_once('. ./../Connections/xml.php'); ?>
<?php
if (!function_exis ts("GetSQLValue String")) {
function GetSQLValueStri ng($theValue, $theType, $theDefinedValu e = "", $theNotDefinedV alue = "")
{
$theValue = get_magic_quote s_gpc() ? stripslashes($t heValue) : $theValue;
$theValue = function_exists ("mysql_real_es cape_string") ? mysql_real_esca pe_string($theV alue) : mysql_escape_st ring($theValue) ;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValu e) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theV alue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValu e : $theNotDefinedV alue;
break;
}
return $theValue;
}
}
mysql_select_db ($database_xml, $xml);
$query_xmldat = "SELECT * FROM uno WHERE id = 1";
$xmldat = mysql_query($qu ery_xmldat, $xml) or die(mysql_error ());
$row_xmldat = mysql_fetch_ass oc($xmldat);
$totalRows_xmld at = mysql_num_rows( $xmldat);
// Includes
include_once(". ./include/padfile.php");
// Create PAD file object for the local file "pad_file.x ml"
// This could also be an absolute local path or an URL!
$PAD = new PADFile("./samples/pad_file.xml");
// Load file
if ( !$PAD->Load() )
echo "Error: Cannot load PAD file.<br>\n";
// Sample Output
echo "<b>Program Name:</b> " . $PAD->XML->GetValue("XML_ DIZ_INFO/Program_Info/Program_Name") . "<br>\n";
echo "<b>Program Version:</b> " . $PAD->XML->GetValue("XML_ DIZ_INFO/Program_Info/Program_Version ") . "<br>\n";
mysql_free_resu lt($xmldat);
?>
[/code]
Comment