I am successfully able to connect from below php program locally.
echo "I am connected";
echo "I am not connected".mysqli_connect_error();
When i invoke the above code, which says "I am connected"
I copied the same file into public_html folder in cPanel, and I am trying to connect to myinit.php by providing the URL like "http://18.104.22.168/myinit.php".
Is this is the right way to provide the URL or am i missing anything else?
Can someone please help me on my query. Do i need to buy domain with GoDaddy to access the php files from an external program(Android)? When i execute the above program locally(locahost/myinit.php), it is able to connect my database in GoDaddy and getting response. But when i keep the same myinit.php in GoDaddy, why my program is unable to access (godaddyipaddress/myinit.php)? To be able to access my GoDaddy php file, do i need to buy GoDaddy domain?
Can someone please confirm?
Hi @udayanem , thanks for posting.
If you have a php file on your cPanel account that is trying to connect to a database on the same cPanel account, you should use 'localhost' as the servername.
You also would not be able view or access your hosted files using the IP address of the hosting plan. You would need a domain name to access view the files on the internet or through a browser.