PDA

View Full Version : Getting Started



markdlv77
11-09-2007, 01:52 PM
Alright, I cannot seem to connect to my godaddy.com database for the life of me. I'm pretty sure I'm just confused in all the syntax - any help would be great! The farthest I've gotten from online help is this:



<?php
//Sample Database Connection Syntax for PHP and MySQL.

//Connect To Database
$hostname="mysql.secureserver.net";
$username="your_dbusername";
$password="your_dbpassword";
$dbname="your_dbusername";
$usertable="your_tablename";
$yourfield = "your_field";
$connection = mysql_connect("$hostname", "$username", "$password");
mysql_select_db("$databasename", $con);

# Check If Record Exists

$query = "SELECT * FROM $usertable";

$result = mysql_query($query);

if($result)
{
while($row = mysql_fetch_array($result))
{
$name = $row["$yourfield"];
echo "Name: ".$name."
";
}
}
?>


I know that I replace username, password, and dbname. I don't actually have any tables.. so I'm not sure what to do with everything else - and also, did I need to change the $hostname?? I'm so lost - everything I try results in 'Error connecting to mysql database.' Thanx for any help.

boogyman
11-09-2007, 02:14 PM
Chances are the database is going to be on the same server as the data files, so try "localhost" as the $host

provided your username / password is correct for the database, if that doesnt work, then you are going to need to contact your provider's tech support and have them help you troubleshoot

djr33
11-09-2007, 06:05 PM
mysql#.secureserver.net, such as mysql7, etc.
Godaddy uses separate servers so you will have to log in remotely. Not the easiest setup, but it works out once you know the right connection.
It took me a while to figure that out; I believe it should be possible to see in your cpanel. I think the phpmyadmin page may also give away that number, but, then again, they might vary it for security reasons. Quite annoying.

markdlv77
11-10-2007, 04:56 AM
Thank you very much for your replies! I'm getting there.. but not quite connected or inserting any data. I've finally found godaddy's hostname and rearranged my php file to look more like this:


<?php
//Sample Database Connection Syntax for PHP and MySQL.

//Connect To Database
$dbhost = "p41mysql97.secureserver.net";
$dbname = "test7777";
$dbuser = "test7777";
$dbpass = "test7777";

mysql_connect($dbhost,$dbuser,$dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());


?>


but this is the rejection I get:
Could not connect: Client does not support authentication protocol requested by server; consider upgrading MySQL client

any ideas what this means??

Twey
11-10-2007, 04:39 PM
Your host needs to upgrade their MySQL client libraries/PHP extensions to match the server.

markdlv77
11-10-2007, 05:17 PM
AHHHHH! You're right! I finally understand why none of my php scripts would work - the cheap account my client got doesn't support them! Well, whoever said go to them directly and ask for support, you're right. I need to figure out some other sort of script (i've written a few asp scripts, but as I understand it, I need to use asp.NET?). Anyway, sorry to annoy any of you advanced guys - and thanx a lot for the help!

djr33
11-10-2007, 08:25 PM
My experience with godaddy is simple-- it's cheap and works very smoothly, for what is in fact setup. There are some hindrances, such as only one ftp user per IP at one time, odd PHP stuff, etc., but if those don't hurt you, then it's great. Anything you need customized, fixed, updated, etc., will be a huge pain though, as the tech support is near worthless-- you call, wait an hour, just to realize they are reading the support files on their site and really don't know anything about PHP, etc. Sometimes you'll push enough and get a manager of some sort, who will just explain something in a vague, confusing way, and it won't really get anywhere.

Twey
11-10-2007, 09:04 PM
Sometimes you'll push enough and get a manager of some sort, who will just explain something in a vague, confusing way, and it won't really get anywhere.Probably meaning that they don't understand it either. I don't think I'd entrust my files to a company that doesn't understand the technology that is the basis of their business.