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.
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'm testing out a website I made in local environment, using Sql Server LocalDB as I said above. The site's done, now I wrote a php script that connects to the database and sends out some emails based on the database contents. I need this script to run automatically, so I've already set up a batch file in the Windows Task Scheduler to run automatically every hour. No problem in this. The issue is that sometimes (pretty often actually) the php scripts can't connect to the database. This seems to happen mostly when I recently "explored" my website, so my question is:
does LocalDB allow only one connection at a time?
If you have other ideas, please tell me. I need to finish testing ASAP.
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.
I wanted to connect to my server via ssh and run a php script to enter some data into the MySQL databases.
I couldn't do this because I didn't have ssh access.
So instead I'm just going to put a php script into one of my web pages and then put the data in the same folder and then run the php by loading the browser
this seems like a really wierd way to enter data into a database?
but is it ok?
Using a PHP script to execute an SQL script should not be a problem (but be sure to delete both afterwards, just so you don't leave an unvalidated/regulated passage into your database out there).
If your webhost provides a MySQL Admin interface (often phpMyAdmin), you should be able to access that through their Control Panel (often called "cPanel" or "Plesk"). You should be able to upload and execute an SQL file through that interface without installing anything else.
Failing that, you should be able to install Adminer, which is a cutdown version of phpMyAdmin which you can then upload to your server and access through a web browser to, again, upload or copy-and-paste your SQL script into.
So you are basically rebuilding phpMyAdmin's behaviour. I would just install phpMyAdmin, but if your php script is protected (.htaccess or similar), then this should be no problem. Look out for timeouts.
A good tool for working with MySQL db is Workbench, but you must have remote access to your db...