PDA

View Full Version : PHP Connect


Danny
January 2nd, 2008, 18:18
Hi Guys!

Im having trouble getting a database and site connected up since i transferred to a new server. The dbconnect.php file is as follows:

<?php
mysql_connect('64.49.219.212', 'xxxx_company', 'xxxx');
mysql_select_db('xxxx_codatabase');
if (!$link) {
die('We are currently updating our website, please come back another time. Sorry for any inconvenience. ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

And the details.php file that calls the dbconnect.php file is as follows:



<?php
include 'dbconnect.php';
$id = is_numeric($_GET['id'])?$_GET['id']:1;
$get = mysql_query("SELECT * FROM xxxxx_codatabase where ID = $id") or die("Mmm pie:" . mysql_error());
while ($row = mysql_fetch_row($get)) {

echo "<img style=\"float: left; padding: 2px;\" src=".$row[1]."><br><br><br><br>";
echo "<br><h2>".$row[2]."</h2><br>";
echo "<strong>Address: </strong><br>".$row[3]."";
echo "<br>".$row[4]."";
echo "<br>".$row[5]."";
echo "<br><br><strong>Postcode:<br></strong> ".$row[6]."";
echo "<br><br><strong>Phone Number:<br></strong>".$row[7]."";
echo "<br><br><strong>Email Address:</strong><br><a href='mailto:".$row[8]."'>".$row[8]."</a>";
echo "<br><br><a href=".$row[9].">".$row[9]."</a>";
echo "<br><br><strong>Contact</strong><br>".$row[11]."";
}
?>

All I keep getting is the error message stated in the dbconnect.php file - any ideas?

Danny

the_pm
January 2nd, 2008, 19:08
Maybe you have to specify the port?

64.49.219.212:3306 - maybe that will get things connected. Otherwise, I'd say it's probably just a small error in your username/password/database name.

Danny
January 2nd, 2008, 20:37
Paul,

I have tried the port number and also have triple checked the database name etc and still no joy :S

Danny

the_pm
January 2nd, 2008, 20:56
Hmm...has the host confirmed your setup is correct?

Danny
January 2nd, 2008, 20:57
Well, im getting the information directly from my host's control panel - copied and pasted. So i guess so.

Do you think it would be worthwhile giving them a shout to double check?

the_pm
January 2nd, 2008, 21:02
If you're positive your connection information is correct, you've set your permissions properly on your database user and your IP/port settings are proper, then yeah, that's when it's time to ask the host if they see any reason you'd be having trouble connecting.

Danny
January 2nd, 2008, 21:03
ok - thanks for your advice!

inimino
January 2nd, 2008, 22:10
<?php
mysql_connect('64.49.219.212', 'xxxx_company', 'xxxx');
mysql_select_db('xxxx_codatabase');
if (!$link) {


I don't see where you assigned anything to $link, you probably meant to store the return value of mysql_connect().

Danny
January 3rd, 2008, 10:02
In honesty, i dont know the first thing about this stuff - im taking stabs in the dark. I managed to get it sorted though with a little help from my host.

Thanks again!