PDA

View Full Version : PHP/MySQL Connections Problems


NathanRX7
1-4-02, 02:28 AM
I'm getting really frustrated and confused here. I have PHPMyAdmin running on my computer, and it connects to my PowWeb database just fine, but for some reason, I cannot get any of my personal PHP scripts to connect. I always get this error trying to access http://www.goldcoastinspections.com/admin/test.php:

Warning: MySQL Connection Failed: Can't connect to MySQL server on 'pluto.powweb.com' (60) in /www/g/goldcoastins/htdocs/admin/test.php on line 4
Could not connect


I'm trying to use my test.php at this point, which looks like this:

#!/usr/local/bin/php

<?php
// Connecting, selecting database
$link = mysql_connect("pluto.powweb.com", "gcpidbuser", "mypassword")
or die("Could not connect");
print "Connected successfully";
mysql_select_db("gcpi")
or die("Could not select database");

// Performing SQL query
$query = "SELECT * FROM DynamicContent";
$result = mysql_query($query)
or die("Query failed");

// Printing results in HTML
print "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
print "\t<tr>\n";
foreach ($line as $col_value) {
print "\t\t<td>$col_value</td>\n";
}
print "\t</tr>\n";
}
print "</table>\n";

// Closing connection
mysql_close($link);
?>

NathanRX7
1-4-02, 02:29 AM
Ha! I just tried running my test.php on my local Web server, and it connected to my database on PowWeb immediately. WTF is going on?

NathanRX7
1-4-02, 03:15 AM
OK this is very strange. About an hour ago (before I originally made this thread) I tried putting localhost in for the server instead of pluto.powweb.com, and I got the same error. I just called PowWeb Tech Support and I spoke to Luke. The first thing he said was that my script had errors and that were no misconfigurations on the server. He also told me he doesn't know anything about PHP or MySQL. He hadn't even looked at my script. I asked him how he could tell me I was wrong without even looking into this at all. So I got him to look at it, and he suggested that I try localhost again. What do you know, it worked this time! I'm not sure if he did anything on his end, but he said he didn't. It all seems kinda fishy to me, but at least it's working now.

jbenalluch
1-4-02, 09:48 AM
is there a phone number to call in case of problems with php?

SimCoWeb
1-4-02, 11:54 AM
When I set up phpmyadmin I also tried inputting the actual MySQL server (terra.powweb.com) and it wouldn't connect. I switched to 'localhost' and it did. So, a lesson learned. :)