In the past I have created a php file that generates the XML and then referenced it in place of the xml file and it has worked. I am trying this with a precompiled flash app and it is not working.
Any ideas why?
It works if I run the script, save it and then reference that file to the swf. I would rather not generate a file to the filesystem if possible. Anyone any solutions?
IF you pull the php page up in the browser are you sure that:
The file has no white space preceding the XML prolog (<?xml version="1.0" ... ?>)
The XML is wellformed
Another thing to check would be to look in firebug on the net panel... it shoudl show all the requests/responses made - including those done by flash (im assuming this is embedded in a web page). Look and make sure your flash is actually looking for the file you think its supposed to be looking for.
Without further information (code etc) I can only guess:
Are you trying to execute it on a server? php needs to be interpreted to generate the actual XML output, so if you don't put it on a webserver (that supports php), no content will be generated and the flash movie just sees the php code.
Check the content of the loaded php/XML file, trace it into some text field for debugging, so you can check if the actual content is being loaded correctly.
Listen for all available events of the URLLoader object. Maybe there is some IO error, you are not seeing. Alternatively you can also use the Flash debug player to see if errors are being thrown.
Also: What ActionScript version are you using?
Without seeing any of the code I would suspect the content type header isn't being set correctly and the php script is sending as html.
You can set the content type with the header funciton:
header('Content-Type: text/xml');
I'd suggest checking if some setting in your php.ini causes the output to be compressed (zlib.output_compression or ob_gzhandler).
Related
I want to use a static page for the homepage for faster load times. (In Wordpress)
But after the converting HTML to PHP with an online converter, it failed, I get only a 500 Issue Code and in the source code is nothing.
There's no point of converting your static HTML page to PHP, unless you want to add some content that's frequently updated (for example posts in your blog).
If you want to create a dynamic website, then you should consider writing it in PHP (you can rename your file's extension, no further conversion is required since every line of PHP code is positioned in between <?php and ?> tags). For example: if your page is called index.html, you can simply change its extension to index.php and it will work fine.
BUT! You'll need a server (or a virtual server) to run your PHP scripts (simply opening the PHP file will result in showing HTML and pieces of PHP code instead of executing it).
Why you want to convert HTML to PHP?
The PHP is generally used to generate HTML pages..
And even at the page load level, a PHP page will have to generate the HTML to be output, while an HTML code already written will only need to be read by the server and served to the client.
So I think you read some article about someone who is not very experienced in the industry.. :-)
This is going to sound like an odd request.
I have a PHP script pulling a mp3 stream from SoundCloud and repeating the stream with the correct headers to allow WinAmp to play the file. But it only shows the local url I have the script running from. Before anyone asks, I am injecting ID3v1 into the file before echoing it.
Is there any way to provide WinAmp with the meta data from php?
Just to clarify, you are effectively proxying an MP3 file from SoundCloud, and you want to embed metadata into it?
Winamp will pick up ID3 tags in an HTTP-served MP3 file. However, if you are using ID3v1, those tags don't exist until the very end of the file. If you want the file to be identified without having to download the whole file, you must use ID3v2 which are typically located at the beginning of the file. (I actually recommend using both ID3v1 and ID3v2 for broader player compatibility, but almost everything supports ID3v2, so it is your choice.)
Now, there is another method but if you use this method the metadata won't be saved in the file when downloaded. You can use SHOUTcast-style metadata. Basically, Winamp and other clients (like VLC) send a request header, Icy-MetaData: 1. This tells the server that it supports SHOUTcast-style metadata. In your server response, you would insert metadata every 8KB or so. Basically, you want the reverse of what I have detailed here: https://stackoverflow.com/a/4914538/362536
In the end, simply adding ID3v2 tags will solve your problem in the best way, but I wanted to mention the alternative option in case you needed it for something else.
I have the following SVG example graph:
http://jovansfreelance.com/bikestats/circos/travels.svg
You can see the source code from there, it's all client-side.
The graph works using sample data. Now, what I need to do is populate is dynamically from the database (or from a file on the server which I could generate using PHP).
Placing PHP code directly into the SVG file doesn't work. Using an onLoad AJAX call doesn't work. It won't let me include jQuery at all. So how do I go about this? I know there's a way but I'm completely new to SVG files.
There's no real difference between generating SVG from PHP and generating HTML from PHP. You just need to override the default content-type header (header('Content-Type: application/svg+xml');).
Of course, you still need a .php file extension as your server won't (by default) be set up to parse .svg files for PHP code.
I am trying to generate a RSS feed from a mysql database I already have. Can I use PHP in the XML file that is to be sent to the user so that it generates the content upon request? Or should I use cron on the PHP file and generate an xml file? Or should I add the execution of the php file that generates the xml upon submitting the content that is to be used in the RSS? What do you think is the best practice?
All three approaches are technically possible. However, I would not use cron, because it delays the update process of your XML-files after the database content has changed.
You can easily embed PHP-Code in your XML-files, you just have to make sure that the files are interpreted as PHP on the serverside, either by renaming them with a *.php extension or by changing the server directives in the .htaccess-file.
But I think that the best practice here is to generate new XML-files upon updating the database contents. I guess that the XML-files are viewed more often than the database content changes, so this approach reduces the server load.
Use a cron to automate a PHP script that builds the XML file. You can even automate the mail part as well in your PHP.
The third method you mentioned. I don't understand how cron can be used here, if there are data coming in users' request. The first method cannot be implemented.
Set the Content-type header to text/xml and have your PHP script generate XML just as it would generate any other content. You may want to consider using caching though, so you don't overwhelm the server by accident.
I've got an idea for a site that would generate png or jpeg screenshots of webpages on the fly. The end user would never see the pages, but the HTML would be turned into a screenshot instead and the end user would see that screenshot.
How can I get started on this? I guess what I'm looking for is some kind of PHP function that takes the HTML as an argument and then produces an image file in a specified location.
As far as I know, PHP does not do this.
You can, however, find a solution using external tools.
Here is how I would do it
Generate the HTML
I would pass this HTML to a external tool using exec. There is, for instance this one.
Then, display the generated picture
http://www.zubrag.com/articles/create-website-snapshot-thumbnail.php