hope someone can help me. I made a unity3d game for webplayer. Now i need to store some data e.g. the time how long someone has played the game in a csv file.
Does anyone know how i can test if my php and javascript for writing to this csv file
in my javascript i habe this line
var postDataURL = "myurl/data.php?";
but i don't have a url til now so i need to test this locally and i don't know what to add for the url i always get this error:
Could not resolve host: C; No data record of requested type
thanks
You will need to set up a web server to run locally. At that point you can target your form submission at http:// localhost/data.php and things will work perfectly. Apache is really easy to set up but you might want to look into something like WAMP (Windows Apache MySql PHP.)
http://www.wampserver.com/en/
First of all in order to access your PHP script to either send or retrieve information You need to use the WWW class with your url.
Next is there a reason that you want to write it to a csv file. If your just trying to store information that is pervasive across all session runs you can write data to player prefs.
PlayerPrefs.SetString("KeyName", Value);
Retrieve the data at any time using
PlayerPrefs.GetString("KeyName")
This is good for keeping high scores and such
Finally to directly answer your question my favorite is installing apache because it sets up in minutes with out havnt to know what your doing
http://httpd.apache.org/
after install find your web root and place the file in there. You can access the file using http://localhost/yourPHPfile.php
Make sure you install php on your machine as well.
Related
I have an admin page that I want to make some changes. The website has been built using php and mysql, by someone else and it is up running.
First thing came to my mind was:
Download source code and make a local copy of everything and work on that and once finished upload to hosting again.(using Xampp)
I also have been advised to make another copy of server and make changes on the server instead of running it locally.
My question is: Second option seems much easier , but does that mean in order to test every little detail I have to save file, upload back to server and run it?
Am i missing something?
This is a very general question but I'm not sure the best way to go about things here.
I have two applications that want to interface. One is a Windows based app that has a database and can send CURL commands. The other is a very simple website with a MySQL database.
The main feature is that these two apps can swap database data between each other. The Windows app is currently using SQLAnywhere but could be converted to MySQL.
Anyway: On the web app there is a js function to dump all data requested into a .txt file, essentially a mysql dump. This function will be called by the Windows app via CURL. It will say
"Hey, dump the data for this table in to a txt file, then let me download it."
What I am unsure of is: Once the request to dump the data is complete, the Windows app will want the file right away. How do I say back to it, "Wait until the file is completed, and then you can download it."
I was thinking of making a dummy file and then a .txt file so the Windows app essentially gets stuck in a loop (with a timeout) until the file is renamed to .txt. Is this a good way to approach this?
Thank you.
I have a website which I'll call website.com that is located on server1. website.com has a field to upload a file. When someone uploads a file on website.com, I don't want the file uploaded to server1, I want it to upload to another server, server2. What is the best way to do this? Can I do this using php, a shell script?
After the file is uploaded to server2, I have a shell script to execute on the file which I will also eventually have to figure out how to run from server1.
I hope this makes sense, thanks in advance.
another possible way to do this is by uploading this file to your website.com site and use CURL to send the image to another server. once this completes you can remove the image again.
see CURL PHP send image for more information.
-- UPDATE --
For SSH connection you need to install additional libraries in order to allow php to make SSH connection. an excellent tutorial can be found here.
-- UPDATE 2 --
The question intrigued me, so i expanded my research. there seems to be another PHP Library phpseclib around on Sourceforge. In the documentation on page 5 there is some information on how it works.
The only good way to make this to work is to read the image to binary, and send it over the the other server, as text and write that into an file, hence creating an image from the source of the original.
Also place the image in a public folder that is accepts calls from your website1 domain, this way you also prevent hot linking your images and saves considerable data.
I also came across this for help with phpseclib.
in the end i wouldnt choose for a solution like this. I would swap your website from server1 to server2, just to keep everything in one place.
Cant you put the script to handle the upload on Server 2?
You can have your HTML pages with the form served for server 1, but call the PHP for the upload from server 2.
Update
For example...
Server 1 has a file index.php which has a form:
<form action='http://server2.com/some_directory/uploader.php' method='POST'>
.... Some form code
</form>
The form on index.php points to a PHP script on server 2, via a URL. That PHP script can now handle the input.
Of course this will only work if server2 is connected accessible from the internet, if not you will have to use some sort of shell script on server 1 to move the files on the internal network when they are uploaded to server 1.
Let me start by saying PHP isn't my forte, I'm usually reluctant to try working with it because of problems exactly like this. The code works fine on my local machine under MAMP and on my server, but doesn't on the clients server :'(
So what am I trying to do, well - save an image from Flash onto the server, simple right?!
I'm using the method described on this site here: http://designreviver.com/tutorials/actionscript-3-jpeg-encoder-revealed-saving-images-from-flash/ but have made a small alteration so that instead of echoing the jpg causing the browser to download it locally, I do an fwrite and an fclose to save it to the server.
Here is my PHP:
I've dona a phpinfo() on my clients server and it's running 5.2.2 my host is running 5.2.11 I don't know if much can have changed in those 9 minor revisions?
I've also read another question on here which suggests making suer always_populate_raw_post_data is set to ON, but it's set to OFF on all of the server environments I've been testing in. I'm doing some XML saving using file_get_contents('php://input') which I've tried but failed to get working with images.
Any help would be gratefully received, I'm happy to post the AS3 as well but it's EXACTLY the same as example I've linked above and works locally. As far as I can tell the problem lies with the PHP.
Cheers.
Is there any reason you're using the HTTP_RAW_POST_DATA? If Flash is sending the file via the POST method, it'd be by far easier to use the $_FILES array. There'd be no need to fopen/fwrite, as the file's already been stuck into a temp dir by PHP. All you have to do is use [move_uploaded_file()][1] to put it wherever you want on the server.
I am trying to create a script that will display the contents of a folder, onto a newsticker, and I was wondering if anyone had a script that could run this. I was thinking probably php, but it has no been working for me.
Thanks for the help
The software I am using is dreamweaver cs4
I'm guessing that you have written some PHP, but are trying to run it locally without a server - for PHP to work you need a server. XAMPP is a good bet to do this locally, or you'll need to upload your file to some hosting that supports PHP.
I'm thinking why you're having trouble with it is because you just copy and pasted the code in a .html file and opening it on your local environment.
With that said, in order for it to run locally, you have to install php and a http server. The code is done on server side, not client side. So either get a hosting service that supports php or download and install your own server and php.
Also, if you already have the above, the code has to be surrounded by a < ?php and ? > tags(without spaces). If you're running it on cli, then you need to make sure you give it execution permission with the path to php, OR execute php < name of script >.
Last, the code you presented provides major security flaws. The first of which is where will the "$dir_path" variable be set? Will that be user given, or will you specify the variable?
Whenever you allow users to view your file system, always make sure you give limitations to it. For example, let's say you did this:
www.example.com/newsticker.php?path=/www/files/newsticker
looks innocent enough, but a clever hacker could say let me try....
www.example.com/newsticker.php?path=/
And so fort.
So be careful and don't allow users to specify directories or execute code.