Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Can I Use PHP To Output A XML File?


I have made a flash file that parses an XML file to get its content. I've tested it with a static XML and it works great. Let's call that XML "xml1".
I have made a MYSQL db and the accompanying PHP files to dynamically add information to the database. This works great.

I tried to use PHP to output an XML file to replace the static one, thus completing the circle and allowing the client to enter data into the db and see it in flash. Let's call this one "xml2".

The flash file won't accept the data from "xml2". I assume it's in some sort of doctype issue. By the way, I thought it might be the fact that the extension of "xml2" is .php instead of .xml, but that doesn't matter. "xml1" was successfully tested with a .php extension.

When I view "xml2" in a browser, it looks like it's being treated like html instead of XML, but when I view the source, it looks exactly like the code from "xml1". What is the difference? Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Output Variable Contents In Htm File From Php File
I have a PHP file. No MYSQL database. I'd like to have it open an .htm file and output the results in the php file to the .htm template. So, for example say there is a bunch of variables called:

$make
$model
$year

I want to open a .htm file and output the contents of $make, $model & $year in the htm format using variables in the htm itself. ie. {make} {model} {year} and it would import the contents of each into the corresponding tag.

Make Output Of File A Variable In A Different File
Can someone tell me how to take the output of a very complex file, and make it a variable in a totally separate file?

Getting A File Via Http Or Evaluating A Php File And Getting Its Output
I need to somehow merge two separate web programs written in php
together (from the user's perspective). This solution won't be
perminant, I just need something done quickly. I was thinking of two
different approches.

One would be to download a processed version (modified so it will
create validating html with the page it's being embeded in) of one of
the programs with the other, then just use print to embed it in the
page. I couldn't find out how to get a file via http here
(http://us2.php.net/manual/en/index.php). Sorry if I missed this in
the docs.

The other would be to process the other program and get it's command
line output, and print that.

If there's a better way to this, I'd be glad to hear it :)

Also, I've never written any php before; so sorry if I missed
something obvious to someone who has.

How To Output A File As An Image File?
I wrote a web counter in php that displays text and images. What I am now trying to do is to convert the output of this php script in an image. Why? Because certain blogs like MSN Spaces do not accept that you embed scripts.

I believe I should look into the imagecreatefrom functions for a solution, but I find very little examples of how to use it, expecially imagecreatefromgd2 and the likes. Ideally I would need a function that allows me to input a URL (like my php script) and that ouputs an image.

Perhpas someone can help me with this?

Popen() Output To A File?
I have a linux binary that I run from a webpage which produces a lot of output and I would like to send that to a file, but nothing seems to work here is an example.. It does however send it all to the httpd "error_log" file

Code:
<?
popen("/home/mybinaryfile > output.file", "w");
?>

Print Output From Log File
I my php script I call a perl script that perl script will create a log file

From the php script I want to read the log file and write the
output to the browser. This operation has to carried out for
till the perl script completes the process. This can be identifed
by [Process Completed] in the log file.

My problem is when I read the first line and print to the browser it
was going fine. Second time when the loop continues it print the sample
content again and again. This has to be avoided and it has the print the
new logs only. Or clear the previous output and print it fresh again.

Ex.

First time

Processing 1...

Second time

Processing 1...
Processing 1...
Processing 2...

Actually in the second time it should print only

Processing 1...
Processing 2...

My Code:
--------

while ($line = fgets($fp))
{
trim($line);
if ($line != "Completed")
{
print $line ."<BR>";
}
else
{
exit();
}
}
fclose($fp);

Sending Output To A File
Lets say I got something simple like:

<?php

echo "yo";
echo "word";

?>

I want all those echos to write to a file instead of printing to the screen
without changing to a different function. Sort of like how in Unix you can
do ./my_prog < file1 to output to a file. In this case I want it all to be
done in code. For example, something like:

<?php

output_to_file_instead_of_screen();

echo "yo";
echo "word";

output_to_screen();

?>

How To Output From File Into Table?
I have this bit of code that opens a file, reads it line by line, and
prints the filename into an image on screen, so i get a big list of
images on the page.

However I want it to output into a table so I can have 2 photos side by
side as it goes through, is there any way of manipulating the code to
output one line into one cell and the next line into the next cell then
back to the first cell again???

<?
$data = file('gallery/captions');

foreach ($data as $line)
{
list ($q, $a) = explode('|' , trim($line) );
echo "<img src='gallery/images/$q' height=100><br>";
echo "$a<br>";
}

?>

Storing Form Output In XML File.
I have a form. I want two actions in it.

first

i want to save all the informations entered in form into a XML file.

second

How to save Mysql query output to a XML file.

Please give me some example (with code).

Running Script Before Output To File
I've got an HTML emailer system where the user creates an HTML file with their input from a form. I've had no problem with this part, neither with the email sending and display HTML. However, before the contents of the HTML email (the HTML file the user creates) gets applied as the message body and emailed via PHP, I would like the file to be passed through PHP and any scripts run that happen to be on the template. My actual portion of email code is here (where the file is read into a variable and the mail is sent):

$emailHeaders = "From: info@domain.com" .
"X-Mailer: PHP/" . phpversion() . "" .
"MIME-Version: 1.0" .
"Content-Type: text/html; charset=utf-8" .
"Content-Transfer-Encoding: 8bit";
$emailMessage = file_get_contents(path/filetosend.php);
$emailSubject = "Email Subject";
$emailRecipient = recipient@domain.com;
mail($emailRecipient, $emailSubject, $emailMessage, $emailHeaders);

How do I make any PHP scripts that are in the "filetosend.php" run before the output is stored into $emailMessage and mailed off?

Including File And Output To Browser
I am not sure I understand the rules as to what exactly gets output to a
browser and when. If I include a text only file or an html file, these will
show up in the browser regardless of where in the script they are included.

When Output File Shows Only Text...
In an attempt to try out some things with php, I have run into a new snag.
The output file is pure text. Basically it's a simple photo gallery using <ul> links to show various thumbnails. In turn, the thumbnails show a bigger image.
All on the same page. My only possible thinking is that it has something to do with the array notation.

$image =array ( );
$image[101]="name.jpg";
Is it correct to say $image = array(999);?
As to define 999 items? as in javascript?

Saving Output As An .html File
I have a script which takes about 20 or so fields as input and creates a big table out of all those. I want to log what happens and I was wondering if there's some way I can save each table as an .html file in my directory.

Output Xml File From Mysql Record
how to get the record from databse directly..but now my application require me to output my record as xml output....so I really need help on it.../some guide ...this is what's my xml gonna be.. Code:

Formatting Of A .txt File Output From A Web Form.
how I can force new lines to happen in a .txt file that stores the results of a webform that a user inputs? As it stands I've tried using and /n tags but they just print to the file and all the text runs on. Also, every time data is appended to the .txt file it appears on the same line.

Write Broswer Output To New File
I have a file (say, output.php) which produces information which is output to a browser at present. That's good. But I need the exact browser ouptut to be turned into a text file (say, output.txt) which will be automatically saved somewhere on my disk, whenever output.php is run. How can I make this happen?

Writing PHP Output To A Seperate File
I'm wondering how can I write the output of a PHP file into a seperate file, kinda like a 'snapshot' of that output.

Is There A Way.... To Output Information/text As A Graphic File.
What I mean is can I write my output of lets say a DB query and save as a .jpg or .png formatted file?

I seriously have no idea and have never seen anything along this line of questioning.

How To Write PHP Standard Output On A Text File?
Using PHP 4.3.11, I want my script not to write standard output on the
webpage, but
on a textfile.

I tried with:

Code: ( text )

Copy Large XML Output To A Local File
I have a URL that when called generate a very heavy XML Feed like:

www.domain.com/generateXML.php?id=products

when i call this URL in the browser i can see a very long XML file generated containing different information..i want to copy this all output to a local file on my server so that i can use that file's info for different tasks on my site...PHP Code:

How To Make Php-output Into .ppt Format (Powerpoint-file)
How can I use php and mysql to create a downloadable .ppt file from
the php-made output?

Dynamic XML + XSLT With Output As A Downloadable CSV File.
I Have a piece of dynamically generated XML, that i need to transform into a downloadable CSV file. There are several restrictions though. First of all i don't want to store output file on the server, and i don't have the XML file (it is being generated, but i do have the XSL file to transform the XML into CSV on my server). Any ideas on how i might do that?

Load The HTML Output Of A File Into A Variable?
How can i load the html output of a file into a variable.. Kind of like include()ing or require()ing a file.. but not echoing the content.. but saving it to a variable..

Can it be done? I dont want to use fgets because they are PHP files.. and i want to get the HTML as if a user opened with a browser..

Read From A Text File, Output To Browser In Japanese
I am trying to store data in a text file and output it to the browser
using PHP. All very easy - if I was using English! the problem is, I
want to use Japanese and I'm finding it a tad difficult to get PHP to
understand. I have two files, a text file containing data to display
and a php file with a script to display the data. I can get the
contents of a text file displayed in English, no problemo, but in
Japanese, it's another story...

All the correct settings are enabled in the php.ini file for Japanese
language support (mb_string, input_encoding, output_encoding settings
etc..etc..) even if I save the text file, to be read from, in
Shift_JIS encoding - I still can't get it to display normally!

here's the script I'm using to read the text file :

<?
$filename="test.txt";
$fp = fopen($filename,'r');
while($line=fgets($fp))
{

//output text file line
print $line."<br>";

}
fclose($fp);
?>

Extra Newlines In Output Text Added By PHP File Include
I have a simple PHP script that outputs a string requested by an Ajax
page. XMLHttpRequestObject.responseText as received from the PHP script
begins with 2 extra newline characters (

MyString):

<?php
require_once('DB.php');
require_once('../myDir/myFile.php');
.......
echo('MyString');
?>

myFile
<?php
$var1 = 1;
$var2 = 2;
$var3 = 3;
?>

If I manually write the contents of myFile.php into the script, there
are no extra newlines in responseText.
Am I missing something?

Making Gmdate Output Equal Date Output
gmdate('F j, Y, g:i a',0) returns January 1, 1970, 12:00 am.
How do I add to the second parameter of the date function to make it
always return that same date, regardless of the time zone?
Intuitively, it seems like date('F j, Y, g:i a',0 - date('Z')) should
do it, but on my system, that's an hour off.

Here's some sample code:

<?
echo gmdate('F j, Y, g:i a',0).'<br />'
echo date('F j, Y, g:i a',0 - date('Z')).'<br />'
echo date('F j, Y, g:i a',0 - date('Z') + 60*60);
?>

And here's the output on my system:

January 1, 1970, 12:00 am
December 31, 1969, 11:00 pm
January 1, 1970, 12:00 am

Will the last echo always return the same thing as the first echo,
regardless of the time zone? If so, why? It seems that the second one
is the one that should do it - not the first one.

CSV Output
I need to write the output of an SQL query as comma-separated values.
So I wrote this, which is almost right:

while($row = mysql_fetch_array($rs, MYSQL_ASSOC))
{
$rows[] = $row;
}
foreach( $rows[0] as $key =$value)
{
echo $key.",";
}
echo "";

foreach ($rows as $row)
{
foreach( $row as $key =$value)
{
echo $value.",";
}
echo "";
}

It first writes a header row, then all the data rows below it. The only
problem is the trailing comma on each line. Is there some clever way of
knowing when I'm on the last element, and so not add the last comma?

Right Output ...
just wondering - which method of output is more fast and use less system
resources. The page being build with outup from multiple functions. So, is
it better to output each function result directly with "echo" construction:

echo "string1";
echo "string2";
................
echo "stringN";

or maybe better to collect all outputs in a variable first:

$out.= "string1";
$out.= "string2";
................
$out.= "stringN";
echo $out;

Maybe someone made a kind of research in this field :)

Output As Csv
I'm trying to output the results of a database query as a csv file

The DB output is in $csv

foreach($csv as $array){
$line[]=implode($delimited_by,$array)."
";
}
header("Content-Type: text/plain");
header("Content-Disposition: inline");

foreach($line as $output){
print $output;


On clicking the link to this file the results are output to the screen.
I can right click and save the output but I'm prompted to save it as a
..php file. How can I make it output as the right kind ( .csv) of file?

Help With Output
I made a php page and the output from a mysql db is as follows:

Author1
Column1
Column2

Author2
Column1
Column2

Author3
Column1
Column2

Author2
Column1
Column2

These are sorted by columndate, so author2 has a column more recent than
author3 and one less recent, so author3 is sandwiched between. I'd like to
be able to have it so that the author 'group' is only shown once. I'd prefer
it to be outputted like:

Author
Column1
Column2

Author2
Column1
Column2

Author3
Column1
Column2

This is my source code:

<?
include ('../connection.php');

$result = mysql_query("SELECT * FROM article_authors,article_columns
WHERE article_authors.authorid = article_columns.columnauth
ORDER BY article_columns.columndate DESC,article_authors.authorname
ASC",$db)
or die (mysql_error());

if ($row = mysql_fetch_array($result)) {

// display list if there are records to display

do {

$authorid=$row["authorid"];
$authorname=$row["authorname"];
$authorcollection=$row["authorcollection"];
$authoremail=$row["authoremail"];

?>
<? if ($currentauthor != $authorname) {

$currentauthor = $authorname;

?>
<?

if ($authorcollection) {

?>
<p><b><a href="columns.php?author=<?echo $authorid?>"><?echo
$authorcollection?></a></b>
</p>
<?

}else{

?>

<p><b><?echo $authorname?></b></p>
<?
}

}

$columnid=$row["columnid"];
$columndate=$row["columndate"];
$columntitle=$row["columntitle"];
$columnauth=$row["columnauth"];
$columnintro=$row["columnintro"];

list ($date_year, $date_month, $date_day) = explode ('-', $columndate);

$string = "$columndate";

$stringArray = explode("-", $string);
$date = mktime(0,0,0,$stringArray[1],$stringArray[2],$stri
ngArray[0]);
$convertedDate = date("d/m/Y", $date);

?>

&raquo;<a href="http://www.efc-online.net/articles/columns/<?echo
$columnid?>"><?echo stripslashes($columntitle)?></a>
<br><?echo stripslashes($columnintro)?> - <?echo $convertedDate?><br>
<?
} while ($row = mysql_fetch_array($result));
}
?>

CGI Output
I have a rather complicated cgi (perl) weather script (ham weather pro) that I want to integrate into a php site. How do I do this?

CSV Output
I need to create a csv file so that the data can be used to be input into MS Outlook. I need to build one row for each contact. I am trying to do this in a while loop, so for each record gathered, it will build the line of data and then break or line end at the end of each record. I am supposing that will have to write each line to the file, this I am not sure.

Best Way To Output Xml From Php?
I've been googling for a few hours now and I can't seem to find any
tutorials on the best way to generate xml from php... most tutorials
tell you how to pase incoming xml xml. I'm used to using template to
output HTML to the browser but I want to start playing with ajax and
outputting XML to the browser anyone have any suggestions or links to
tutorials?

PHP Output Help
I was flicking through a PHP book (one of the teach in 24 hour ones)
and I came across something I had never seen before in PHP. It was a
method of printing out without using the print method, it was something
like :

<?= $myVar; ?>

Is this an out dated method? Is it compatible with all versions of PHP
(since implementation at least)?

Output Into Table
I'd like to output some query results in a table, each result in it's own column and row. Here's an example --

***********************************
IF ($result){
echo "<center><table><tr><td>";
while ($r = mysql_fetch_array($result)) {
$number = $r["stock_number"];
$description = $r["item_description"];
echo "$number<br></td>";
echo "<td>$description<br>";
}
echo "</td></tr></table>";
} else
{
echo "No data.";
*********************************

Except it doesn't work correctly. What is the proper way to accomplish this?

Output Buffering (or Something)
I just attended an ASP.net course and I was just wondering if a type of technology also exists in PHP.

Its some kind of "tag" that tells the server if it should query the database for the data requested by a client, or if it should just return a cached version of the results from the query, thus saving on traffic to the database.

In ASP.net one could specify in a simple tag what the timeout on such a tag should be so that the code would only actually query the database for instance once every 10 minutes, and use cached versions of the data anytime else.

So: Can this functionality be found in PHP/MySQL somewhere?

Piping PHP Output?
Does anyone know whether it's possible to 'pipe' the output of one PHP script into another?

Essentially, what I want to do is have one PHP script (Script A) call another PHP script (Script B), which might retrieve data from a database, format it the way it would normally appear on the screen, but instead capture it in a variable (or some other method) in the script (Script A).

PHP Output To .csv - Garbage
I have a problem with the output that I am writing to .csv file. Below is the php code used to output contents into the .csv file: PHP Code:

Using PHP To Output A Form
I have a login system that gives registered users unique userIDs and stores their registration info in a MySQL DB. Now the tricky part:

I need a PHP that outputs a simple HTML form with a list of all the members (and their name and email) in the DB, with a checkbox next to each. This form must be specific to whomever is logged on, such that the data (s)he enters only goes into the relevant row, column or table of the individual whose checkbox was checked.

Summing up: I need a way for
(1) a form to display all the listed members in a MySQL DB and
(2) to have the info selected in the form entered into the relevant row, table, or column of the individual selected.

Problem With PHP Output
I have an html menu that I renamed menu.php. I then have a download
program which uses an index.php file. I did the standard <?php
include("menu.php"); ?command and I see the menu. However, it messes
up the php index file. When I go to download a file it just opens the
file on the screen for some reason rather than showing a popup window
asking where to put the downloaded file. I then tried to just add the
html code into the index.php file and that didn't work either. When I
take out the <?php include("menu.php"); ?command the script works
perfect. I then tried another download script and it puts the menu on
the screen, but the php file that runs after the menu is not centered
and looks bad. Does anyone know what the problem could be? Is it
something with my .htaccess file?

Random Output
I have a didyouknow section and would like to rotate or randomize the output. I have this code, but it's not working, PHP Code:

Formatted Output
I want to display a number value (such as 1234567) in the form, 1,234,567. How can I do it?

Printable Output
Is there a standard technique, in a PHP/MySQL Web Application, for users
to be provided with printable-quality output - e.g. business invoices -
created for them on the fly?...

Printable Output
Is there a standard technique, in a PHP/MySQL Web Application, for users
to be provided with printable-quality output - e.g. business invoices -
created for them on the fly?...

Get Output From Ssh2_shell
I try to use SSH2 in PHP to connect to a linux server. Here is the
code:
<pre>
$connection = ssh2_connect('xxx', 22);
if( !$connection ) die("Failed to connect");

if( ! ssh2_auth_password($connection, 'aaa', 'bbb') )
die("FAIL");

$s = ssh2_shell($connection, "vt100");
if( !$s ) die("Can not attach stdio.");

fwrite($s, "ls /tmp");

$o = fread($s, 100);
echo $o;
</pre>

But I can't get any output using fread. How can I get the
output(STDOUT)?

PHP Output Garbled
solving my php serving problem?
I'm relatively new to this.

The problem is: all php output appears client side as garbled text (in
firefox, and IE wants to download the page, but gives an error that
downloading isn't possible).
I had a working system (suse 9.0 / apache2 /php4/mysql) and upgraded
to suse 9.1 (i know, "if it aint broke, dont fix it", but i did it
anyway)

Apache runs and serves html pages, but no php. mysql runs fine as
well. I've checked the mime type, which is there
( application/x-httpd-php phtml pht php )
But that's about all I can think of. It's probably a common config
problem,

Sending PDF As Output
I have a pdf file (syllabus.pdf) on the server. I have written the
following PHP code. It correctly finds the file, but it is sending the file
back as text I think because I'm seeing the binary in the browser rather
than seeing the PDF loaded by Adober Reader. I've done with with Perl, but
I've never tried this with PHP. Can someone point out what I'm doing wrong
and how to fix it so that my PHP script can serve PDFs?

<?php
header("Cache-control: no-store
");
header("Content-type: application/pdf

");
readfile("$DOCUMENT_ROOT/syllabus.pdf");
?>

How To Buffer Output
vishal here. can anyone tell me that how to buffer output and then send
the output to client at a time.

what is my problem is that i have a php file which runs query on
database and takes some time to get query result. so what i want is i
want to buffer output till the query returns result and then send the
buffered output to client at a time.

How To Output Semicolon With Php
my problem: I want to print :
7] Xerox: print '<a href='.
'"javascript:;"'.
"onClick='hideAll(); showHideLayers ('s6','','show')'>
test</a>";

with php

but I can't get it work becouse php ends reading efter ; but I have to have
it printed.. how do I acheff it?


Copyright © 2005-08 www.BigResource.com, All rights reserved