cancel
Showing results for 
Search instead for 
Did you mean: 

Why i am unable to access public_html files from a program

I am successfully able to connect from below php program locally.

myinit.php

<?php
$mysql_dbname="MyDB";
$mysql_username="MyUsername";
$mysql_password="MyPassword";
$mysql_servername="148.72.88.29";

$con=mysqli_connect($mysql_servername,$mysql_username,$mysql_password,$mysql_dbname);

if($con)
echo "I am connected";
else
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://148.72.88.29/myinit.php".

 

Is this is the right way to provide the URL or am i missing anything else?

 

Thanks,

Uday

2 REPLIES 2

Re: Why i am unable to access public_html files from a program

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?

Moderator
Moderator

Re: Why i am unable to access public_html files from a program

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.

 

Gary - GoDaddy | Community Moderator
24/7 Support | Check System Status