Current location: Hot Scripts Forums » Programming Languages » PHP » Embeding PHP code in XML??


Embeding PHP code in XML??

Reply
  #1 (permalink)  
Old 01-27-08, 06:32 AM
ausgezeichnete's Avatar
ausgezeichnete ausgezeichnete is offline
Wannabe Coder
 
Join Date: Oct 2007
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
Rolleyes Embeding PHP code in XML??

I have a XML file contains images
XML Code:
  1. <content width="368" height="450" bgcolor="cccccc" loadercolor="ffffff" panelcolor="5d5d61" buttoncolor="5d5d61" textcolor="ffffff">
  2.     <page src="pages/01.jpg"/>
  3.     <page src="pages/02.swf"/>
  4.     <page src="pages/03.swf"/>
  5.     <page src="pages/04.jpg"/>
  6.     <page src="pages/05.jpg"/>
  7.     <page src="pages/06.jpg"/>
  8.     <page src="pages/07.swf"/>
  9.     <page src="pages/08.jpg"/>
  10.     <page src="pages/09.swf"/>
  11.     <page src="pages/10.jpg"/>
  12.     <page src="pages/11.swf"/>
  13.     <page src="pages/12.jpg"/>
  14.     <page src="pages/13.jpg"/>
  15.     <page src="pages/14.jpg"/>
  16.    
  17. </content>

My problem that i want to insert php code in the file.XML
but it never read it

am trying to edit a Flash page Flip and images comes from this xml fil
what can i do??
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-27-08, 06:34 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Change the extension to .php and fake it with mod_rewrite.
Code:
RewriteEngine On
RewriteRule ^file\.xml$ file.php
(Save the above as ".htaccess" in the root directory)

This way PHP will parse it, and your browser will think it's a regular XML file.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-27-08, 07:05 AM
ausgezeichnete's Avatar
ausgezeichnete ausgezeichnete is offline
Wannabe Coder
 
Join Date: Oct 2007
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
ok i will save the file as Pages.php instead of Pages.xml
but how can i fake it??????????
and then i will make a new file and put the code file.htaccess(in the root or in teh same folder of them??)
and in the code will be
Code:
RewriteEngine On
RewriteRule ^Pages\.xml$ Pages.php
is this ok??
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 01-27-08, 07:08 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Save it in the same folder as "Pages.php"

Now go to your web browser and open Pages.xml and it'll display the contents on Pages.php.

The .htaccess code will fake it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 01-27-08, 07:20 AM
ausgezeichnete's Avatar
ausgezeichnete ausgezeichnete is offline
Wannabe Coder
 
Join Date: Oct 2007
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
well,i made Pages.php like that
PHP Code:


<?php require_once('../../Connections/mystique.php'); ?>
<?php
mysql_select_db
($database_mystique$mystique);
$query_Recordset1 "SELECT * FROM gallery_thumb";
$Recordset1 mysql_query($query_Recordset1$mystique) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?>

<?php do{?>
<content width="368" height="450" bgcolor="cccccc" loadercolor="ffffff" panelcolor="5d5d61" buttoncolor="5d5d61" textcolor="ffffff">
    <page src="../../allwebcodesign/Admin/gallery/<?php echo $row_Recordset1['foto']; ?>"/>
    
</content>
<?php }while($row_Recordset1 mysql_fetch_assoc($Recordset1));?>
and made a new file called Pages.htaccess and put the code u gave me in it
ok??and put it ine the same folder
so the folder now contains Pages.xml Pages.php Pages.htacess
but it still reads from the pages.xml
and if i removed it , nothing works????????????
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 01-27-08, 07:30 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
The file with the code I gave you should just be called ".htaccess" (with the dot at the beginning, and without the quotes)

You save this .htaccess file in the same folder as Pages.php

Pages.php should look like this:
PHP Code:

<?php

header
('Content-Type: text/xml');

require_once(
'../../Connections/mystique.php');

mysql_select_db($database_mystique$mystique);
$query_Recordset1 "SELECT * FROM gallery_thumb";
$Recordset1 mysql_query($query_Recordset1$mystique) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?>

<?php do{?>
<content width="368" height="450" bgcolor="cccccc" loadercolor="ffffff" panelcolor="5d5d61" buttoncolor="5d5d61" textcolor="ffffff">
    <page src="../../allwebcodesign/Admin/gallery/<?php echo $row_Recordset1['foto']; ?>"/>
    
</content>
<?php }while($row_Recordset1 mysql_fetch_assoc($Recordset1));?>
Once you've saved the .htaccess file where you should, go to your web browser, and browse to Pages.xml (Pages.xml doesn't exist in reality, but the htaccess file will tell apache to use Pages.php when Pages.xml is being requested.)

There should be no file called Pages.xml in your folder. Just the .htaccess file and Pages.php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 01-27-08, 07:47 AM
ausgezeichnete's Avatar
ausgezeichnete ausgezeichnete is offline
Wannabe Coder
 
Join Date: Oct 2007
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
i brwosed to Pages.xml and gave me that
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.





the probelm,that i have a file called Defualt.html,it reads from teh Pages.xml to dispaly images on it
now.it dispalys nothing!!!!!!!!!!!

i dont know what is wrong or to know where is the wrong???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 01-28-08, 06:38 AM
ausgezeichnete's Avatar
ausgezeichnete ausgezeichnete is offline
Wannabe Coder
 
Join Date: Oct 2007
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
well,let me explain to u the case
am using a bookflip application downloaded from the net
http://www.flashpageflip.com/
its is a html pages contains flash which gets its images from the xml file
and the above r the code in the XML file

my problem now,that i wan this images to be dynamically from the database
using PHP
so,am trying to find the way to embed the php into the XML file
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Require Forum website project code in php language suaveshiva PHP 4 04-30-07 04:21 PM
PHP code formatter... jumbo1 The Lounge 1 03-19-07 01:01 PM
PHP, XML images. nightlord PHP 1 07-05-06 10:09 PM
Write in a XML file with php pallabmondal123 PHP 2 04-15-06 06:34 AM
PHP and XML dwoody PHP 11 04-05-06 04:32 PM


All times are GMT -5. The time now is 05:13 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.