I know that when we execute a PHP script on localhost, the server runs the code and does the required processing and simply outputs the result to the browser. Recently, I was reading about socket_create function which creates a connection for server and client to communicate, but I have a doubt regarding it. Below is what I think, please correct me if i am wrong.
When I run my program (which uses socket_create) by typing http://localhost/myprog.php... The prog commands localhost to make a open a socket. This is ok, but what if I want to create socket on some other server? (Below are two options, please tell me which is correct)
If I still run the script on http://localhost does that mean the
script will run on localhost and localhost will make a socket on the
other server? And if I want to give some input to the other server
the input will pass through localhost.
I can't do it as told above, I would have to run my script on other
server to create a socket on it.
PHP script is like any other program on machine. If you access script which is on localhost, and this script creates socket then script on your local machine connect to the other server, retrieves output, pass it back to script. If you access some remote host, then script is executed on this remote host - that's only difference.
So the answer is 1.
Related
I would like to access a local mysql database through my php script hosted on a remote server. Is there a way to code a script, that I save on the local mashine, and receives queries from my remote php script, executes, and the results are submitted back to the script?
How is this technology called?
I know, that I could just open the mysql port on my firewall, but I don't want to do that.
The technology is called AJAX.
This is a fairly simple question, yet I haven't been able to find a simple answer.
If I use curl on Server1 to access a PHP file on Server2, is the code in that file executed on Server2?
I have a script on a remote server that I need to be able to execute from my main server. The code should be executed on the remote server where the PHP file resides.
Yes, it is. Same as you'd enter that address to internet browser.
I am a newbie to asterisk and found it really interesting! I've been able to create a dial plan that works perfect, but, I am stuck on working with FastAgi. I want asterisk to run my PHP script that is placed on my windows server remote machine. I have called fast AGI as show below:
exten => s,n,AGI(agi://192.168.0.101/tts.php?number=123456789&pin=123)
But asterisk CLI always shows Connection refused or Connection refused for the url 192.168.0.101:4573/tts.php?number=123456789&pin=123
I wonder why is it appending the port by its own.
Need help to go through this Connection refusing thing, I have tried turning off the fire wall but still failure.
P.S: My PHP script is a simple one like the normal PHP script, nothing special.
Thank You in advanced
I have solved the question by my self. The only problem was that default port "4573" as my remote PC was not configured to listen this port. Any how, I solved it by simply adding a port to my IP like this "IP:80" and the connection was complete with response of 0.
Any how the script never fired after this so I use CURL function to get my php script running.
Thank You
So I have a php script that connects to a MySQL database that runs fine on my server and my schools server when it is ran. I currently have to have my script connect to another database but get the following error
Host "host" is not allowed to connect to this MySQL server
I did search and found the option to use GRANT ALL PRIVILEGES "." for the user but wanted to know if it is possible (Since I have to submit these files to the persons FTP) to run it after I upload the file to the ftp server. My guess is where the database is located as well. HTML runs fine off the ftp but when I try to open the php script All I see is just the code instead of anything running. Is it impossible to run a PHP script off the ftp using ftp://ftpserver/script.php?
Or am I looking at this the wrong way?
I apologize for any beginner annoyance as I've never really worked with FTP and how they function when it comes to this.
Any help is appreciated.
Using PHP, exec('php test.php'); will execute a separate PHP script on the command line.
What if test.php lives on another server, but within the same network? Can I specify that server's local IP address for the shell command to be run? What about a remote IP address? I could always install Apache on the second server and call the remote script via http, but would like to avoid that if possible.
Thanks, Brian
I can think of two options:
Use exec() to execute a program that connects to this other server and does whatever.
Set up a web service on the receiving server, and have the sending server send a request.
Regardless of what you choose to do, you'll need some setup on the receiving end, for the obvious reasons Dan Grossman pointed out.