php error - cannot connect to server

8 posts / 0 new
Last post
#1 Mon, 06/08/2009 - 19:38
eboughey

php error - cannot connect to server

Hi,

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.

Mon, 06/08/2009 - 20:28
andreychek

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? -Eric

Mon, 06/08/2009 - 20:37 (Reply to #2)
eboughey

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 //////
define("DATABASE_SERVER","$db_host_name");

////// Enter Database Name //////
define("DATABASE_NAME","$the_client_db_name");

////// Enter Database UserName //////
define("DATABASE_USERNAME","$db_user_name");

////// Enter Database password //////
define("DATABASE_PASSWORD","$db_user_password");

////// Enter Your site Personalized Builder URL uptill the folder in which you save these scripts //////
define("YOURSITE_URL","$site_url");

////// Enter Your site physical PATH URL //////
define("PBBUILDER_PATH",$the_server_path);

////// Temp File Upload Path ///////
define("UPLOAD_PATH",PBBUILDER_PATH."/uploaded");

////// Export Data Path ///////////
define("EXPORT_PATH",PBBUILDER_PATH."/export");

/////// PBuilder Report Path ///////
define("PBREPORT_PATH",$the_server_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"); return; }//end of connection function

Mon, 06/08/2009 - 20:50 (Reply to #3)
andreychek

Hmm, what's in the file named "pb_setup.php"?

That may be where the variables are setup. -Eric

Mon, 06/08/2009 - 21:25
eboughey

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

var isIE,isNS,isW3C var range = ""; var styleObj = ""; if (document.layers) { isNS = true; isIE = false; isW3C = false; range = "layers["; styleObj = "]" } if (document.all) { isNS = false; isIE = true; isW3C = false; range = "all."; styleObj = ".style"; }

<

table cellpadding="0" cellspacing="0" border="0" height="100%"> 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 .=  "<b>Problem with new username or password:</b> see below. <br><br>\n";
    }
    if (!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+))*$",$client_email, $regs) )
    {
        $dont_go_ahead = 1;
        $message .=  "<b>Problem with new email address:</b><br>Either blank or illegal characters found.<br><br>\n";
    }
    if ((strlen($user_name) < 4) ) {
        $dont_go_ahead = 1;
        $message .=  "Username must be at least four characters long<br>\n";
    }
    if (eregi("[^0-9a-zA-Z]", $user_name, $regs))  {
        $dont_go_ahead = 1;
        $message .=  "Illegal characters in username<br>\n";
    }
    if (eregi("^[0-9]", $user_name, $regs))  {
        $dont_go_ahead = 1;
        $message .=  "Username must begin with alpha character.<br>\n";
    }
    if ((eregi("[^0-9a-zA-Z]", $client_password, $regs)) ) {
        $dont_go_ahead = 1;
        $message .=  "Illegal characters in password<br>\n";
    }
    if ($client_password != $client_password_2) {
        $dont_go_ahead = 1;
        $message .=  "Client passwords do not match.<br>\n";
    }
    if (strlen($client_password) < 5) {
        $dont_go_ahead = 1;
        $message .=  "Client password must be at least five characters long.<br>\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?<br>\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 "<i>now using new database</i><br>\n";
Mon, 06/08/2009 - 21:33 (Reply to #5)
andreychek

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. -Eric

Mon, 06/08/2009 - 21:52
eboughey

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 /home/virtual/domainname/var/www/html

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

Wed, 06/17/2009 - 13:42
ronald
ronald's picture

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

Topic locked