简体   繁体   中英

Upload a PHP script to another server and run it to connect to my database

I have created a search engine zoken.co.cc and had option manual submit of site and downloading a file populate.php By uploading populate.php in others ftp and opening the it index itself itself in database.

For example: A site www.abc.com want submit site in my search engine and chooses automatic submission and download file ( populate.php ) and had upload in ftp server. and open page www.abc.com/populate.php . Then a page appears and had

Warning: mysql_connect() [function.mysql-connect]: Host '10.1.1.27' is not allowed to connect to this MySQL server in /home/a1091216/public_html/populate.php on line 10

ERROR: Could not connect to database    

I know that his and my FTP servers are different but can it save.

That's because the remote server is not allowed to connect to your database server using that username. You can set the database user to allow connections from % , which means "The user logging in with this username can connect to the database server from any host".

Is it really important to run a PHP script on someone else's server? I can see the following problems:

  • User does not trust your PHP script and ends up not submitting.

  • User does not have PHP installed on the server, or is running a server to serve sites built using ASP, rendering the PHP script useless.

  • The PHP file will contain the database username and password. Who is to say that the webmaster won't grab these out of the PHP file and mess with your database (even if the user account is only allowed to read/write from 1 table)?

If I were you, I would just let them download a text file with a random string inside. Ask them to upload this to the root of their submitted site. Then every 5 minutes (until the site is marked as verified), have your server go out and using CURL retrive the text file from their site. Check the random string inside and then populate your database.

yes, its possible to connect to a mysql database which is in placed on one server if the script requesting for that connection is coming from another server.. .
The first thing is to make sure the host mysql server has networking turned on and port 3306 (I think that's the number) open on your firewalls. I'd expect that both of those are off by default.
Personally, I'd be very suspicious of doing this. Leaving mysql open to the internet makes me very uncomfortable. Suggest you try and find a better way to do this.

Just re-read and realized I should be clearer. In my.cnf (the mysql config file, probably in /etc) there's a variable, something like networking=no, or skip-networking; I forget the specifics. Anyway, that needs to be set to enable networking then you need to restart mysqld.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM