Please forgive the simplicity of this question. The answer will be obvious to many of you. But since I'm completely new to php and JSON, and I can't find a concrete answer on Google, I need to ask.
I have the following:
Client side Android app
mySQL database on server
JSON in between
The question is very simple. Where on the server do I put the php file? Any directory? A specific location? I just need a simple working answer. Not concerned about security or anything fancy at this stage. Please help.
Also, does anyone know of a very simple tutorial that talks about php, json, and working on the server side for someone like me who's completely new to it?
Your server must be available with a one of the given folders
public_html
www
htdocs
if any of the folder you can see in your server then this is the place where you need to place your php files
basic Introductory Tutorial for PHP with examples
tizag.com
Basic Introductory Tutorial For JSON
JSON
JSON with PHP
As long as the php file is accessible by http you are fine. So pretty much anywhere.
here is a tutorial. http://www.itnewb.com/tutorial/Introduction-to-JSON-and-PHP
To run your php script you will need an http server on your server that handles php script.
For example you can use the apache web server with mod_php. You then can put your php file in the server default web folder or configure another one.
Related
ve been trying to make a server side site recently on Github but the php code will not run, I have put in a .htaccess but it still wont work, I was wondering if I need to put some library into it to interpret it but other peoples php codes seem to be working without anything like that. Any Ideas?
From https://help.github.com/articles/what-is-github-pages/:
GitHub Pages is a static site hosting service and doesn't support server-side code such as, PHP, Ruby, or Python.
I have a php file that handles contacting me from my site via email. I don't know much about php but when i use node all i have to do is start up my node server file and the whole site launches. My front end is html/javascript and the only "backend" is the contact_me.php. I need to be able to have my php running so that it works with my site. I know nothing about apache. If you could tell me how to setup what i need to setup or point me in the right direction that would be awesome. I have tried reading the documentation for apache to no avail.
PHP mail manual will help you set up mail in php.
If you are new to this, its better to use some inbuilt libraries like PHPMailer which have decent enough documentation for beginners.
I am working with some code for uploading images to a server on android. I am working on my local xampp server. I do have Restler and PHP installed on it for REST services at the moment.
I was working modifying the code in this tutorial.
I installed an external jar file for the http client errors. But I cannot install coldfusion as it appears to require a commercial license of some sort and this is what this tutorial is using. As I said, most of the code is in that tutorial besides downloading the latest http client jar file here. What I'm really asking is what alternatives to this cfc function are there? And preferrably what php alternatives are there? Please let me know if I should clarify anything else. Thank You.
Cormac, the only ColdFusion consideration here is that the blogger uses a CFC as a web service within one of their Java classes (it's not great to have a dependency like that in there, but oh well). So what you're gonna need to do is to find out what that web service does, and roll your own. On the basis of the info you have given is, we can't tell you what the web service does... I recommend you touch base with the blogger and ask them. They'll almost certainly flick you the code, and then we can have a look at that if you need further help.
How can I access my php script from a Python script?
I need my Python script to be able to access the variables within the php script. (By the way, I'm new to php and Python.)
Thanks in advance.
If I understand it correctly, you have a service in PHP, and want to communicate with another one in Python.
Now, this is not really related to PHP or Python: this is quite a classic issue of integration and there are several ways to accomplish it; without more details about your problem, it may be very difficult to be specific about a solution and what kind of approach could be the better for you, but below you can find some ideas.
You could for instance save the status from PHP service in an ad-hoc table in the database, and then query it from the Python service.
Another way could be to use a RESTful approach: the information is available as a resource, accessible via a GET query; in PHP you would have a small handler that would just return a small JSON (or XML, if you like that kind of stuff), and in Python you would have instead the client. Of course, there are security issues to consider, but I think you got the idea.
For more information, I recommend you having a look at an interesting series written some time ago by Paul Stovell about integration. It is very accessible, and shows several approaches - although not all of them apply to your current issue.
Elaborate. Is the PHP file local? On a webserver? Where's the python file?
If the php file is on a server with the python file, use an exec statement.
If the python file is local and the php file is on a server, then you need to use urllib.
If both are local, write an interpreter...
I wrote a script in php that allows me to get a list of files in a directory as an array, parse each one for a particular string, and then it displays all of the files that contain the search string.
My IT staff won't let me install php on the server though. Can this be done with javascript without ActiveX? Everything I could find on this is pretty old.
Alternatively, is there a way to make php functions like opendir and readir work on a remote server?
Thanks
Nor JavaScript / ActiveX will help you do what you need to do if the directories are on a remote server. So no, can't be done.
This would be quite the security violation if you could. You will need to have something installed on the server that has file system access. If this is on an internal network, you may be able to simply enable directory browsing... but there aren't any client-side-only solutions to this.