473,602 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Load XmlFile from a mysql database.

1 New Member
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 1753
pronerd
392 Recognized Expert Contributor
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 Recognized Expert Top Contributor
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
9737
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 . "\" into table addresses"; $result = mysql_query($SQL) or die(mysql_error()); The file is located in the same directory as my .PHP file. How do I generate a relative address for this file so that it can be found?
0
3487
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 test script to allow me to perform some transactional database testing to load test a MySQL 4.0.13 database server running behind some apache webservers. I have obtained an ODBC driver from MySQL and have some specific queries i would like to use in...
0
1481
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 transforms. It need to run on Windows 2000 and be able to run it as a service, or as a cron task if running under Unix. Any suggestions? --
0
6677
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 be able to place the PHP file on the server, and I guess you probably can't do that either. Talk about catch 22... The only other way I can think of is to install MySQL on a machine you control, then import the data there using the method I...
0
1668
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 7.2 using same MySQL version. Recently our master database server (2 AMD Cpu + 2Gb memory + 2Gb swap space) started to suffer from memory outages because of heavy load. During day available free memory is changing from 200Mb to 5Mb and when...
1
16057
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 is for the sake of security. What does that mean ?
3
2742
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 phpinfo, the "mysql api client is ver. 4.0.25" - I have no idea how this relates, if at all, to the mysql engine's version. background:
3
1892
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 the version PHP to 5. and the problem started. The load on the server skyrocked between 39-52. And I seriously have no idea what to do about it. This is remotedly hosted servise and there are number of connections from other websites to my...
39
2555
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 things: - MySQL : as much as possible, he keeps query results in RAM, but apparently, each is session-specific, which means that results can't be shared with other users.
0
8401
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8404
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8054
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8268
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6730
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5440
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2418
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.