Can't access db on godaddy

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

sleepydad
Forum Commoner
Posts: 75
Joined: Thu Feb 21, 2008 2:16 pm

Can't access db on godaddy

Post by sleepydad »

I set up a database with one table on godaddy today (my first time doing it). The database name is 'kronies'. The table name is 'players'. I tested it locally using MAMP, and all worked perfectly, but I'm having trouble since it posted to www. I'm using the following in my php:

Code: Select all

 
 
@ $db=new mysqli('hostname provided by godaddy', 'username', 'password', 'kronies');
 
 
I'm floating my php in my root folder. Is that correct, or should it be in a subfolder somewhere? I'm using other php on godaddy without a problem, but none of it to access mysql. I copy/pasted hostname, username and password from godaddy site into my php, so I assume there aren't any typos. When I type in the URL to the php, I get a blank page with no source code.

Any suggestions would be greatly appreciated.

Thanks in advance -
sleepydad
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Can't access db on godaddy

Post by Benjamin »

Hi, more than likely that isn't your actual database name and user name as they are probably prefixed with something. Regardless, your error log will shed light on the problem.
sleepydad
Forum Commoner
Posts: 75
Joined: Thu Feb 21, 2008 2:16 pm

Re: Can't access db on godaddy

Post by sleepydad »

Thank you for your input. I'm a newbie to php and mysql, so pardon me asking a bonehead question. How do I access my error log? Also, when I signed up with them (godaddy), I was directed to a page where I could copy/paste my host, uname and password into my script so I doubt there are any typos. However, I'm wondering about your reference to prefixes??

Do I need to upload any other files (ie php.ini). Is there anything I need to change on those files? I'm running php scripts on the same server without a problem, but none of them call on mysql. I'm assuming that because my other php runs fine that all necessary files, again php.ini, etc, are unnecessary as a separate upload because my godaddy server has that embedded.

I just accessed my mysql info through godaddy.com. Would my host name be something similar to:

xxxmysqlxx.secureserver.net

??

That's what I've copy/pasted into my php directly from their site.

Sorry again for the 'dumb' questions. I've never uploaded a database, and have about four months experience under my belt using php/mysql.

Your patience is greatly appreciated. Godaddy tech support has all but shut me off because we're just going round and round for going on four days now.

sleepydad
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Can't access db on godaddy

Post by Benjamin »

Maybe they don't have mysqli installed. Try testing your credentials by placing this in a file and running it. Don't forget to change the database name.

Code: Select all

 
try {
     if (false === ($link = mysql_connect('localhost', 'mysql_user', 'mysql_password'))) {
         throw new Exception("Could not connect to database");
     } 
 
    if (false === mysql_select_db('dbname', $link)) {
         throw new Exception(mysql_error($link));
     } 
 
    if (false === ($resource = mysql_query("SELECT 1+1 AS total", $link))) {
         throw new Exception(mysql_error($link));
     } 
} catch (Exception $e) {
     echo $e->getMessage();
}
 
sleepydad
Forum Commoner
Posts: 75
Joined: Thu Feb 21, 2008 2:16 pm

Re: Can't access db on godaddy

Post by sleepydad »

Okay, I took your code and saved it to my server at URL:

http://www.cannedads.net/phptest.php

I switched out the

if (false === ($link = mysql_connect('localhost', 'mysql_user', 'mysql_password')))

with the info that godaddy provided me:

if (false === ($link = mysql_connect('xxxmysqxxx.secureserver.net', 'MYUSERNAME', 'MYPASSWORD'))) {

I also switched out

if (false === mysql_select_db('dbname', $link))

with

if (false === mysql_select_db('MYDATABASENAME', $link))

I tried both with 'try' and the opening/closing curly braces and without. I wasn't sure if that was instructions or part of the script. Newbie, remember?? : )

Regardless, both yielded same results.

Godaddy gave me the option to choose php 4 or 5 when I created the databases. I chose 5.

Thanks again for your assistance.

sleepydad
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Can't access db on godaddy

Post by califdon »

sleepydad wrote:I just accessed my mysql info through godaddy.com. Would my host name be something similar to:

xxxmysqlxx.secureserver.net

??
Yes, that's your hostname. You will also need your mysql password and your database name, which on godaddy is the same as your mysql username.

I don't know about mysqli, since I have never used it. That could be the issue.
Godaddy tech support has all but shut me off because we're just going round and round for going on four days now.
I find that quite surprising. I've been a godaddy customer for a couple of years and found their tech support unusually good. I have 10 databases under my one godaddy account (different domains) and have never had a bit of a problem.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Can't access db on godaddy

Post by Benjamin »

Ok, if you didn't receive any errors, it connected ok. It would appear that mysqli is not supported on that server. Note the i following mysql.
sleepydad
Forum Commoner
Posts: 75
Joined: Thu Feb 21, 2008 2:16 pm

Re: Can't access db on godaddy

Post by sleepydad »

Following is the script that godaddy gave me. It's posted at:

http://www.cannedads.net/godaddyTest.php

Code: Select all

 
 
<?php
//Connect To Database
$hostname='xxxmysqxxx.secureserver.net';  // auto filled by godaddy website
$username='MYUSERNAMEHERE'; // auto filled by godaddy website
$password='MYPASSWORDHERE'; // auto filled by godaddy website
$dbname='MYDBNAMEHERE'; // auto filled by godaddy website
$usertable='MYTABLENAMEHERE'; // auto filled by godaddy website
$yourfield = 'name'; // row name from my table
 
mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db($dbname);
 
$query = 'SELECT * FROM $usertable';
$result = mysql_query($query);
if($result) {
    while($row = mysql_fetch_array($result)){
        $name = $row['$yourfield'];
        echo 'Name: '.$name;
    }
}
?> 
 
 
Same darned results, and straight from the horse's mouth. I'm stumped.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Can't access db on godaddy

Post by Benjamin »

astions wrote:Ok, if you didn't receive any errors, it connected ok. It would appear that mysqli is not supported on that server. Note the i following mysql.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Can't access db on godaddy

Post by califdon »

Maybe it's just a typo when you entered it here in the forum, but in that last post you left the "L" out of mysql in your $hostname example. But I was just going to suggest almost the same thing as godaddy did:
I think that's your problem. mysql <> mysqli. Unless they tell you that they support mysqli, they probably don't. Try this:

Code: Select all

<?php
  $host='xxxmysqlxx.secureserver.net';  // use your information, of course
  $dbusr='.......';
  $dbpwd='.......';
  mysql_connect($host,$dbusr,$dbpwd) or die(mysql_error());
  mysql_select_db($dbusr) or die(mysql_error());
  $sql='SHOW TABLES';
  $result=mysql_query($sql);
  while($row=mysql_fetch_assoc($result)) {
    foreach($row as $key=>$val) {
      echo "<br />$key : $val";
    }
  }
Since essentially that failed, let me ask if you are able to see your database and your tables in the phpMyAdmin control panel in your godaddy account? Are you familiar with how to get to that? The one real bad part of godaddy is its awful customer interface. You have to go to My Hosting Account (don't get sidetracked into their Hosting Plans advertising!), Manage Account (Control Panel), then Databases.

P.S. Geez, I just checked my account, and they've changed the initial control panel screen again just since the last time I logged in, maybe a week ago!
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Can't access db on godaddy

Post by Benjamin »

@califdon, both my script and godaddies script connected successfully.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Can't access db on godaddy

Post by califdon »

astions wrote:@califdon, both my script and godaddies script connected successfully.
Oh, sorry, I guess I didn't read all of the posts. I was mostly answering because I use mysql databases on godaddy shared hosting myself. So he's all set now?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Can't access db on godaddy

Post by Benjamin »

No - Script has a fatal or parse error. It's using mysqli.

Blank page probably is throwing a fatal error because mysqli is not installed. You are going to have to find your error log or turn on display_errors and error_reporting, otherwise we are just guessing here.
sleepydad
Forum Commoner
Posts: 75
Joined: Thu Feb 21, 2008 2:16 pm

Re: Can't access db on godaddy

Post by sleepydad »

Jack's scripted echoed out "Tables_in_kronies : players ". That's the first time anything's echoed out. I think we're onto something. Don't know exactly what, but something! : )


http://www.cannedads.net/godaddyTestII.php
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: Can't access db on godaddy

Post by Benjamin »

astions wrote:
astions wrote:Ok, if you didn't receive any errors, it connected ok. It would appear that mysqli is not supported on that server. Note the i following mysql.
Post Reply