1

I am getting a connection when connecting to MySQL after moving my code to my host server. The error is:

PHP Warning:  mysqli_connect(): (HY000/2002): Permission denied in
/hermes/bosoraweb112/b883/ipg.iancramergraphicscom/newdev/getContent.php
on line 15

Here's my code:

    $server = '127.0.0.1';
    $username = 'admin_user_1';
    $password = '********';
    $dataBase = 'db_content';

    $conn = mysqli_connect($server, $username, $password, $dataBase);

I have found some others with this problem that have solved it by changing the SELinux settings, but I am not sure how to even do that to try it.

If it is SELinux, how do I access that to edit?

Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555
Ian
  • 73
  • 1
  • 8
  • Verify you're able to connect to the database from the host/ip you are using for this. – drmarvelous Jan 03 '16 at 23:09
  • I am able to connect – Ian Jan 03 '16 at 23:11
  • From what? The same host? Your personal machine? – drmarvelous Jan 03 '16 at 23:12
  • I may not have understood. How can I test the connection? I am very new to this. – Ian Jan 03 '16 at 23:21
  • can you use cli (command line interface)? – davejal Jan 03 '16 at 23:39
  • I can to a degree, but I am not sure how to remotely access the server or if I have permission. I am using iPage and it's hard to find information on their site. – Ian Jan 03 '16 at 23:42
  • searching for "iPage mysqli_connect" on SO leads to [this](http://stackoverflow.com/questions/31381552/cant-connect-using-mysql-connect-to-database-in-ipage-com-hosting) which suggests that you should use `username.ipagemysql.com`. – VolkerK Jan 03 '16 at 23:48
  • From what I understood from that post it says use that format for the server name in place of '127.0.0.1'? If that's right it just gives me another error that it can't find the address. – Ian Jan 04 '16 at 00:01

1 Answers1

-1

Your server name is at ipage database management base, like this one : enter image description here

SRC : http://www.ipage.com/knowledgebase/beta/article.bml?ArticleID=463

Just after version there is a server name (from their knowledge base). That's the server name (username or site name) and not 127.0.0.1.

Secondly, are you sure that iPage accepts remote database connexion ? From what I know, they don't. Meaning your query will only be accepted if it is on a file hosted there and not from your local development computer or anything.

About remote and Ipage : Host (iPage) does not allow remote access. So how can I reach/edit my database?

Community
  • 1
  • 1
Chaibi Alaa
  • 1,346
  • 4
  • 25
  • 54
  • Thanks. This is actually the very first server name I tried, but this gives me: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known. I am hosting the PHP file on the server, so that shouldn't be the problem. – Ian Jan 04 '16 at 00:22
  • And that's when you try to connect from your local machine I guess – Chaibi Alaa Jan 04 '16 at 00:22
  • No this is all on the server – Ian Jan 04 '16 at 00:24
  • You attached a user (admin_user_1) to the database and granted him requested privileges ? – Chaibi Alaa Jan 04 '16 at 00:25
  • Yes this user has all permissions. I also have it echoing a "Connection Successful" if the connection fails. This response shows up every time. Why would it do that if I did not connect? – Ian Jan 04 '16 at 00:29
  • 1
    Then is stricly a problem by them. I would advice opening a ticket there, from what you are telling, it can't be caused by you. Sometimes, DNS may cause this error(by them) other times a simple server refresh would make everything corrected (also, by them) – Chaibi Alaa Jan 04 '16 at 00:47
  • It did turn out to be a problem with them! I just did a live chat with them and they fixed it immediately after I told them the problem. I should have contacted them a long time ago! – Ian Jan 04 '16 at 01:07