Say I have a C++ program that any user can download on their machine. I’d like to give the user the capability to upload content via this program to some remote database that I’ve set up.
My strategy is to have the C++ program call a PHP script that will connect to the database when prompted. However when I attempt to connect to a remote server that isn’t localhost like the following call:
mysql_connect("website.com", "user", "pass");
It gives the error:
PHP Warning: mysql_connect(): Lost connection to MySQL server at 'reading initial
communication packet', system error: 111
Is there some way to allow any user who downloads this program the ability to connect and upload content? Further more, is there a better way that could also work? Thanks.
If you want to directly upload from the user’s machine why use PHP? Use the mysql C API. Just enable remote access in the mysql server.
But I won’t advise to do that, it’s better to have your own webserver, with it’s “local” mysql, and then you won’t have connection problems and expose your DB server to the outer world.