php error - cannot connect to server


I’m running a php script that gives me the error ‘cannot connect to server’. Can anyone give me any clue what causes this type of error?

The software is supposed to be tied to my web address so I’m wondering if they didn’t set it up right.

Well, do you have the full error? Does it say specifically what host/address it’s trying to connect to? And if so, is it the correct one?

Are there any additional errors in the site’s error_log that make the problem more clear?

that was the full error. It didn’t say anything else at all. Here’s the part of the script that should allow me to enter the info, but it doesn’t and the resulting error.

//declaring all the variables

require ("pb_setup.php");

////// Enter Database Server //////

////// Enter Database Name //////

////// Enter Database UserName //////

////// Enter Database password //////

////// Enter Your site Personalized Builder URL uptill the folder in which you save these scripts //////

////// Enter Your site physical PATH URL //////

////// Temp File Upload Path ///////

////// Export Data Path ///////////

/////// PBuilder Report Path ///////

////// Enter Error Text //////
define("ERROR_TEXT","Error : You are not authorized to view this page");

// connection function
//makes connection with mysql database
function connection()
$connection = mysql_connect(DATABASE_SERVER,DATABASE_USERNAME,DATABASE_PASSWORD) or die(“cannot connect to the server”);
$db = mysql_select_db(DATABASE_NAME,$connection) or die(“cannot select the database”);
}//end of connection function

Hmm, what’s in the file named “pb_setup.php”?

That may be where the variables are setup.

pb_setup is empty, but pb_install has the following (I didn’t add the creation of tables):

<?php ############################ reset($_POST); while(list($id,$value) = each($_POST)) { $$id = $value; } reset($_POST); ############################ // File path definitions $dev_machine_name = "localhost"; $the_server_name = $_SERVER['SERVER_NAME']; $js_path = "./"; //It is with respect to the Root of the site $pbFolder = "/personalized"; include("adminHeader.php"); include("adminTopLinks.php"); //TODO Write your own header function here print <<<END
Personalized URL Application 
END; // determine the folder physical path $the_server_path = $server_path; if (isset($action)) { ///////////////////////////////////////////////////////// // Create Database if ($action == "Create Database") { ///////////////////////////////////////////////////////// // Connect to the database $link = @mysql_connect($db_host_name, $db_user_name, $db_user_password); if($link) { print "Connecting to MySQL
\n"; $dont_go_ahead = 0; } else { print "Could not connect to database".mysql_error(); $dont_go_ahead = 1; } $message = "

"; if ((eregi("[^0-9a-zA-Z]", $user_name, $regs)) || (eregi("[^0-9a-zA-Z]", $client_password, $regs)) || (eregi("^[0-9]", $user_name, $regs)) || ($user_name == "") || (strlen($user_name) < 4) || (strlen($client_password) < 5) ) { $dont_go_ahead = 1; $message .= "Problem with new username or password: see below.

\n"; } if (!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+))*$",$client_email, $regs) ) { $dont_go_ahead = 1; $message .= "Problem with new email address:
Either blank or illegal characters found.

\n"; } if ((strlen($user_name) < 4) ) { $dont_go_ahead = 1; $message .= "Username must be at least four characters long
\n"; } if (eregi("[^0-9a-zA-Z]", $user_name, $regs)) { $dont_go_ahead = 1; $message .= "Illegal characters in username
\n"; } if (eregi("^[0-9]", $user_name, $regs)) { $dont_go_ahead = 1; $message .= "Username must begin with alpha character.
\n"; } if ((eregi("[^0-9a-zA-Z]", $client_password, $regs)) ) { $dont_go_ahead = 1; $message .= "Illegal characters in password
\n"; } if ($client_password != $client_password_2) { $dont_go_ahead = 1; $message .= "Client passwords do not match.
\n"; } if (strlen($client_password) < 5) { $dont_go_ahead = 1; $message .= "Client password must be at least five characters long.
\n"; } $the_file_name = "./pb_setup.php"; $fd = fopen($the_file_name, "wb"); if (!$fd) { $dont_go_ahead = 1; $message .= "Can't write to the local directory. Did you CHMOD the folder to 777?
\n"; } fclose($fd); if ($dont_go_ahead != 1) { $base64_encoded_password = base64_encode($client_password); $db = mysql_select_db($the_client_db_name,$link) or die("cannot select the database"); print "now using new database

Yeah – I think there’s another piece somewhere in the mix that I’m not seeing.

What you need to find is where all the variables in that first file you posted are set. There’s variables such as “$site_url”.

There may be a config file or similar that’s setting those up – and you just need to make sure the values for them are correct for your server.

Actually I think I’ve just found what I need. It is asking for the server path though and I’m not sure which it is. I’m not at home so I can’t physically see the folder…

/var/www/html or

I think it’s the 2nd one but I’m not 100% on that one.

default setting is /home/domainname/public_html if you have more than 1 domain on it or changed the path yourself.