These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for php error - cannot connect to server on the new forum.
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.
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
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 ///////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////// // 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
Hmm, what's in the file named "pb_setup.php"?
That may be where the variables are setup. -Eric
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 = "
";
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
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.
default setting is /home/domainname/public_html if you have more than 1 domain on it or changed the path yourself.