Free Web Hosting Forum
(#1 (permalink))
Old
Junior Member
chellehman is on a distinguished road
 
Posts: 4
Join Date: Aug 2012
Default database.php - 08-10-2012, 12:55 PM

I'm very new to web programming with PHP. Im having a problem understanding the connection to the database via the database.php file. Would the host be "000webhost.com"? And I thought the username and password would be what I use to log into mysql but I am getting "Access Denied".

Thank you,

Shelli
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
Doug Lochert's Avatar
Senior Member
Doug Lochert is on a distinguished road
 
Posts: 364
Join Date: Jun 2012
Location: Canada
Default 08-10-2012, 01:16 PM

You must setup a MySQL database, username and password before you can use it.
The username will be something like aXXXXXXX_username
The database name will be something like aXXXXXXX_dbname
The MySQL host is something like mysql22.000webhost.com
You can find the exact info in your cPanel under MySQL after you have setup the database.

aXXXXXXX will be your 000webhost account
Reply With Quote
(#3 (permalink))
Old
Junior Member
chellehman is on a distinguished road
 
Posts: 4
Join Date: Aug 2012
Default 08-10-2012, 01:34 PM

Hi Doug - Thank you.
I did already create the database and username/password.
I changed the host to mysql22.000webhost.com and now I am getting the error:
Warning: mysql_connect()[function.mysql-connect: {my ip address} is not allowed to connect to this MYSQL server in {my database.php file}
Reply With Quote
(#4 (permalink))
Old
Doug Lochert's Avatar
Senior Member
Doug Lochert is on a distinguished road
 
Posts: 364
Join Date: Jun 2012
Location: Canada
Default 08-10-2012, 01:40 PM

mysql22.000webhost.com was only an example.
You must find your "specific" sql server address in your cPanel, under MySQL
Reply With Quote
(#5 (permalink))
Old
Junior Member
chellehman is on a distinguished road
 
Posts: 4
Join Date: Aug 2012
Default 08-10-2012, 01:54 PM

yea - I had already tried that earier - same error. I think I had that part correct in the beginning but kept changing things around because of errors.
My cpanel:
Username axxxxxxx
Password mypswd
Home Root /home/axxxxxxx
Server Name myserver.000webhost.com
IP Address myip

database: 'axxxxxxx_MYDBNAME'
database username: axxxxxxx_MYUSERNM

My database.php file

// Connect to the mysql database.
$conn = mysql_connect("myserver.000webhost.com", "axxxxxxx_MYUSERNM", "mypswd") or die(mysql_error());
mysql_select_db('axxxxxxx_MYDBNAME', $conn) or die(mysql_error());

?>

Error:
Warning: mysql_connect()[function.mysql-connect: {myip} is not allowed to connect to this MYSQL server in {my database.php file}
Reply With Quote
(#6 (permalink))
Old
Doug Lochert's Avatar
Senior Member
Doug Lochert is on a distinguished road
 
Posts: 364
Join Date: Jun 2012
Location: Canada
Default 08-10-2012, 02:23 PM

Quote:
Originally Posted by chellehman View Post
// Connect to the mysql database.
$conn = mysql_connect("myserver.000webhost.com", "axxxxxxx_MYUSERNM", "mypswd") or die(mysql_error());
mysql_select_db('axxxxxxx_MYDBNAME', $conn) or die(mysql_error());
Assuming you have all other login info correct, I can only guess that you are still using the incorrect mysql host (highlighted above). This host address is not the same as your website url. It should be like mysql##.000webhost.com as per your cPanel/MySQL info, and not the account info on right side of cPanel showing your website address etc.

If you are usingthe correct MySQL host address, then I can only guess that something is amiss with your IP. Are you using a proxy server to hide your IP?
Reply With Quote
(#7 (permalink))
Old
Junior Member
chellehman is on a distinguished road
 
Posts: 4
Join Date: Aug 2012
Default 08-10-2012, 02:42 PM

OK .. I found the my ## in mysql## by noticing it in the url while logged into phpmyadmin. I made it through step 1 ... now all the rest.
Thank you so much for your help.
Reply With Quote
Reply

Tags
database connection

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com