Code: Select all
@ $db=new mysqli('hostname provided by godaddy', 'username', 'password', 'kronies');
Any suggestions would be greatly appreciated.
Thanks in advance -
sleepydad
Moderator: General Moderators
Code: Select all
@ $db=new mysqli('hostname provided by godaddy', 'username', 'password', 'kronies');
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();
}
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.sleepydad wrote:I just accessed my mysql info through godaddy.com. Would my host name be something similar to:
xxxmysqlxx.secureserver.net
??
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.Godaddy tech support has all but shut me off because we're just going round and round for going on four days now.
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;
}
}
?>
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.
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";
}
}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?astions wrote:@califdon, both my script and godaddies script connected successfully.
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.