473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Load XmlFile from a mysql database.

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???

Expand|Select|Wrap|Line Numbers
  1. <?php require_once('../../Connections/xml.php'); ?>
  2. <?php
  3. if (!function_exists("GetSQLValueString")) {
  4. function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
  5. {
  6.   $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  7.  
  8.   $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
  9.  
  10.   switch ($theType) {
  11.     case "text":
  12.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  13.       break;    
  14.     case "long":
  15.     case "int":
  16.       $theValue = ($theValue != "") ? intval($theValue) : "NULL";
  17.       break;
  18.     case "double":
  19.       $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
  20.       break;
  21.     case "date":
  22.       $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
  23.       break;
  24.     case "defined":
  25.       $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
  26.       break;
  27.   }
  28.   return $theValue;
  29. }
  30. }
  31.  
  32. mysql_select_db($database_xml, $xml);
  33. $query_xmldat = "SELECT * FROM uno WHERE id = 1";
  34. $xmldat = mysql_query($query_xmldat, $xml) or die(mysql_error());
  35. $row_xmldat = mysql_fetch_assoc($xmldat);
  36. $totalRows_xmldat = mysql_num_rows($xmldat);
  37.  
  38.  
  39. // Includes
  40. include_once("../include/padfile.php");
  41.  
  42. // Create PAD file object for the local file "pad_file.xml"
  43. // This could also be an absolute local path or an URL!
  44. $PAD = new PADFile("./samples/pad_file.xml");
  45.  
  46. // Load file
  47. if ( !$PAD->Load() )
  48.   echo "Error: Cannot load PAD file.<br>\n";
  49.  
  50. // Sample Output
  51. echo "<b>Program Name:</b> " . $PAD->XML->GetValue("XML_DIZ_INFO/Program_Info/Program_Name") . "<br>\n";
  52. echo "<b>Program Version:</b> " . $PAD->XML->GetValue("XML_DIZ_INFO/Program_Info/Program_Version") . "<br>\n";
  53.  
  54.  
  55. mysql_free_result($xmldat);
  56. ?>
  57.  
Mar 5 '08 #1
2 1743
pronerd
392 Expert 256MB
If you are new to using forms you may want to google rules on proper form etiquette. It will help you get much better responses.

Specifically :
1. Questions about PHP and or SQL would be better off in a form for PHP and or SQL.

2. Just saying it does not work does not tell any one much. What happens? Getting a null value, an error, etc.

3. When providing source code for help it is better to post the code the that is acutally failing. That looks like the code that you where loading the XML from a file with. If your question relates to loading it from a data base then that is the example code that should be provided.


I do not know PHP, but it looks like your problem may relate to your SQL query. Unless your database API includes a function that converts the result set to an XML object then you are probably trying to pass straight text to and XML defined object.
Mar 24 '08 #2
jkmyoung
2,057 Expert 2GB
Whenever i try to load the $PAD variable from a database is always return an error. Can you guys help me with this???
Could you show the code where you try to load the variable from a database? It may be a casting problem, or similar problem.
Mar 24 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Bruce A. Julseth | last post by:
When I execute this SQL statement in my PHP code, I get an error "File '.\Address.txt' not found (Errcode: 2)" $File = addslashes(".\Address.txt"); $SQL = "Load Data InFile \"" . $File . "\"...
0
by: Michael Weiner | last post by:
I know this is quite a bit off topic, but i was wondering if anyone else out there had any experience with Segue's Silk Performer load testing tools. More specifically, i am trying to compile a...
0
by: Howell, Scott | last post by:
I am looking for a simple extraction/load program to load data daily from a Progress 8.3B database via ODBC to a mysql 3.23.57 database. It does not necessarily need to do any data-type...
0
by: Donald Tyler | last post by:
Then the only way you can do it that I can think of is to write a PHP script to do basically what PHPMyAdmin is trying to do but without the LOCAL in there. However to do that you would need to...
0
by: kayra | last post by:
Hi all, I want to get your opinions on how to increase available/free memory and performance on a heavy volume database server. I have MySQL 4.0.13 running on RH 7.2 replicated to another RH...
1
by: Ray in HK | last post by:
What are the differences between LOAD DATA INFILE and LOAD DATA LOCAL INFILE ? I found some web hosting company do not allow using LOAD DATA INFILE but allow LOAD DATA LOCAL INFILE. The reason...
3
by: nsh | last post by:
mailing.database.mysql, comp.lang.php subject: does "LOAD DATA" EVER work?!? I've tried EVERYTHING! version info: my isp is running my web page on a linux box with php ver. 4.4.1 according to...
3
by: ewunia | last post by:
I am running the tagboard service on my server. Few months ago I bought the new dedicated server with Dual Xeon 3.2 GHz and 2GB Ram. The board is written in PHP with Mysql. Not long ago I updated...
39
by: Gilles Ganault | last post by:
Hello, I'm no LAMP expert, and a friend of mine is running a site which is a bit overloaded. Before upgrading, he'd like to make sure there's no easy way to improve efficiency. A couple of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.