Jump to content

[SOLVED] Call to undefined function db_connect()


teamfresh

Recommended Posts

Hi everyone. I have been trying to install a php script on my domain for 3 days now and I am completely stuck. :( I have installed php scripts before, and never had a problem untill now. You should also know that I'm a noob to php  :-[ and I have been trawling the internet for the last 3 days trying to find a solution to this problem without having to bother anyone but i cant.

I am really hoping someone can help me with this.

I installed the script as set out in the install.txt 

 

ie- filled out config.php

 

then pointed my browser to mysite.com/install.

 

filled out the database information.

 

this installed the tables in my database.

 

I got a message telling me the install was a success (i checked and the tables have indeed been installed) the message said I should point my browser to mysite.com/siteadmin to log in as admin.

 

and this is where my problem is. When i point the browser to /siteadmin or even the site itself - I get the following message on a blank screen

 

Fatal error: Call to undefined function db_connect() in /home/content/t/e/a/teamfresh78/html/nine/config.php on line 98

 

I am stumped. I thought after trawling the net it might be something to do with php.ini but to be honest I dont have a clue and the more I look around the net for an answer the more confused I become! I would be forever in your debt if you could help me out on this.

Thanks in advance

teamfresh

 

Link to comment
Share on other sites

try to find out in which file db_connect() function is defined, and then require it into your config.php

 

Ok I think that the function is defined in dblib.php (this is in sub directory lib)

 

<?

if (!isset($DB_DIE_ON_FAIL)) { $DB_DIE_ON_FAIL = true; }
if (!isset($DB_DEBUG)) { $DB_DEBUG = false; }

function db_connect($dbhost, $dbname, $dbuser, $dbpass) {
global $DB_DIE_ON_FAIL, $DB_DEBUG;

if (! $dbh = mysql_connect($dbhost, $dbuser, $dbpass)) {
	if ($DB_DEBUG) {
		echo "<h2>Failure trying to connect to $dbhost as $dbuser</h2>";
		echo "<p><b>MySQL Error</b>: ", mysql_error();
	} else {
		echo "<h2>Database error.</h2>";
	}

	if ($DB_DIE_ON_FAIL) {
		echo mysql_error();
		die();
	}
}

if (! mysql_select_db($dbname)) {
	if ($DB_DEBUG) {
		echo "<h2>Can't select database $dbname</h2>";
		echo "<p><b>MySQL Error</b>: ", mysql_error();
	} else {
		echo "<h2>Database error.</h2>";
	}

	if ($DB_DIE_ON_FAIL) {
		echo mysql_error();
		die();
	}
}

return $dbh;
}
function grab_content($what)
{
global $DB_DIE_ON_FAIL, $DB_DEBUG;
$query = db_query("select ".$what." from administration where id='1'") ;
$content= db_fetch_array($query);
return $content[0];
}

function db_query($query, $test=false, $terminate=true, $silent=false) {

global $DB_DIE_ON_FAIL, $DB_DEBUG;

if ($test) {
	echo "<pre>" . htmlspecialchars($query) . "</pre>";

	if ($terminate) die;
}

$query = mysql_query($query);

if (! $query && ! $silent) {
	if ($DB_DEBUG) {
		echo "<h2>This query failed:</h2>";
		echo "<pre>" . htmlspecialchars($query) . "</pre>";
		echo "<p><b>MySQL Error</b>: ", mysql_error();
	} else {
		echo "<h2>Database error.</h2>";
	}

	if ($DB_DIE_ON_FAIL) {
		echo mysql_error();
		die();
	}
}

return $query;
}

function db_fetch_array($query) {
return mysql_fetch_array($query);
}

function db_fetch_row($query) {
return mysql_fetch_row($query);
}

function db_fetch_object($query) {
return mysql_fetch_object($query);
}

function db_num_rows($query) {
return mysql_num_rows($query);
}

function db_affected_rows() {
/* INSERT, UPDATE, or DELETE*/

return mysql_affected_rows();
}

function insert_id() {
return mysql_insert_id();
}
function db_num_fields($query) {
return mysql_num_fields($query);
}

function db_field_name($query, $fieldno) {
return mysql_field_name($query, $fieldno);
}
?>

am I right? If so how do I then require it in config?

Link to comment
Share on other sites

Try putting

require('lib/dblib.php');

somewhere at the beginning of your config.php

 

ok I tried that and some graphics came up this time! but there were also a few error messages. and cant log in. also I noticed that regarding the config.php the line below where the original error pointed contains similar to what you asked me to include below is the part I am talking about

 

 /* load up standard libraries */
require("$CONFIG->libdir/stdlib.php");
require("$CONFIG->libdir/dblib.php");
require("$CONFIG->libdir/genlib.php");


session_start();
session_register("SESSION");

/* connect to the database */
db_connect($CONFIG->dbhost, $CONFIG->dbname, $CONFIG->dbuser, $CONFIG->dbpass);
require_once("$CONFIG->libdir/general.php");


?>

 

I have tried replacing this with what you said and I also tried putting what you said nearer the top and removing the original also but it still does not work.

Link to comment
Share on other sites

ok... We might be on to something... Can you find where $CONFIG variable is declared?

not sure If i understand...

is it defined at the top of config.php?

 

<?

class object {};
$CONFIG = new object;

/* Edit the database connection parameters below */

Link to comment
Share on other sites

I am not sure but is this it? general.php (in lib directory)

<?
global $CONFIG,$_SESSION,$REMOTE_ADDR;
$ref=$_SERVER['HTTP_REFERER'];
$new=0;
if(isset($_SESSION["sponsorname"]["username"])){$sp=$_SESSION["sponsorname"]["username"];}
elseif(isset($_SESSION["sponsor"]["username"])){$sp=$_SESSION["sponsor"]["username"];}
if(!isset($sp))
{$new=1;$sp2=db_fetch_array(db_query("select username from users order by rand() limit 0,1"));$sp=$sp2["username"];}
$q=db_fetch_array(db_query("select * from users where username='$sp'"));
session_register("sponsor");
$_SESSION["sponsor"]=$q;
session_register("sponsorname");
$_SESSION["sponsorname"]=$q;
if(!$_SESSION["random1"]["firstname"]){
$q1=db_fetch_array(db_query("select * from users order by rand() limit 0,1"));
session_register("random1");
$_SESSION["random1"]=$q1;}
$who=$_SESSION["sponsor"]["username"];
if($new){$q3=db_query("INSERT INTO `hits` (`username` , `refer` , `ip` , `date` ) 
VALUES ( '$who', '$ref', '$REMOTE_ADDR',now())");}
?>

Link to comment
Share on other sites

looked at every page of the script but I am no closer to figuring out where it is. The only place I think it could be apart from above is the config.php itsself

 

<?

class object {};
$CONFIG = new object;

/* Edit the database connection parameters below */

$CONFIG->dbhost = "localhost";
$CONFIG->dbname = "database-name";
$CONFIG->dbuser = "database-user";
$CONFIG->dbpass = "password";

/*Edit the path to the scripts below*/

$CONFIG->wwwroot     = "/hsphere/local/home/complete-path.com/";

//Site URL -please use the "http://www.mysite.com" format.
$CONFIG->siteurl     = "http://www.your-domain-name.com";

// the support email address-all the mails from the contact form will go there
$CONFIG->support     = "your-email@address.com";

//Site name-this will be shown on the header,and footer,and also on every email sent
$CONFIG->sitename    = "moneyfunctions";

//Payment fees:---Use the same format,otherwise the forms won't work

//for admin
$CONFIG->adminfee="2.50";

//for sponsor
$CONFIG->sponsorfee="5.00";

//for random membbers
$CONFIG->randomfee="5.00";

//Payment processors
//Change TRUE with FALSE if you don't want to use one of them.
//However,the registration form requires a valid paypal AND stormpay address to work
$CONFIG->allowpaypal=true;
$CONFIG->allowstormpay=false;
$CONFIG->allowegold=false;
$CONFIG->allowintgold=false;


//Site  colors
$CONFIG->bgcolor    = "#ffffff";//Background color
$CONFIG->darkercolor="#ADAEAE";//headings color-
$CONFIG->lightcolor="#ffffff";//content color,table borders
$CONFIG->showstats=true;//show the site stats on the left side

/*             READY !!!
*             Do NOT  EDIT BELOW!!!
*       OPEN THE INSTALL.PHP FILE IN YOUR BROWSER NOW
*/















//Site header:you can choose one of ours or you can place your own.
//Just see the header.gif files from the images folder.For custom headers,


$CONFIG->headerfile    = "$CONFIG->siteurl/images/header_1.jpg";

//Edit below ONLY if you changed the current site structure
$CONFIG->templatedir = "$CONFIG->wwwroot/templates";
$CONFIG->libdir      = "$CONFIG->wwwroot/lib";
$CONFIG->imagedir    = "$CONFIG->wwwroot/images";


                                   
$CONFIG->primu=$CONFIG->siteurl."/&#106&#111&#105&#110&#46&#112&#104&#112&#63&#115&#116&#97&#103&#101&#61&#112&#114&#105&#109&#117";
$CONFIG->adminul=$CONFIG->siteurl."/&#106&#111&#105&#110&#46&#112&#104&#112&#63&#115&#116&#97&#103&#101&#61&#97&#100&#109&#105&#110&#117&#108&#13&#10";
$CONFIG->hidden="&#104&#105&#100&#100&#101&#110";
$CONFIG->complete=$CONFIG->siteurl."/&#117&#115&#101&#114&#115&#47&#99&#111&#109&#112&#108&#101&#116&#101&#46&#112&#104&#112";
/* load up standard libraries */
require("$CONFIG->libdir/stdlib.php");
require("$CONFIG->libdir/dblib.php");
require("$CONFIG->libdir/genlib.php");


session_start();
session_register("SESSION");

/* connect to the database */
db_connect($CONFIG->dbhost, $CONFIG->dbname, $CONFIG->dbuser, $CONFIG->dbpass);
require_once("$CONFIG->libdir/general.php");


?>


I really dont know. I think I may give up :(

Link to comment
Share on other sites

Yeah, that's the right place.

 

It seems that the install script didn't configure all these options properly, so perhaps you have to change them by hand.

 

$CONFIG->wwwroot seems to be responsible for at least part of your problems.

Link to comment
Share on other sites

this is the copy of config i have on my web root. (password marked out) so if thats what you ment by filling it out manually, I was asked to do that in install.txt before going to /install

 

<?

class object {};
$CONFIG = new object;

/* Edit the database connection parameters below */

$CONFIG->dbhost = "mon0924901575559.db.4585220.hostedresource.com";
$CONFIG->dbname = "mon0924901575559";
$CONFIG->dbuser = "mon0924901575559";
$CONFIG->dbpass = "----------";

/*Edit the path to the scripts below*/

$CONFIG->wwwroot     = "http://www.moneyfunctions.com/nine";

//Site URL -please use the "http://www.mysite.com" format.
$CONFIG->siteurl     = "http://www.moneyfunctions.com/nine";

// the support email address-all the mails from the contact form will go there
$CONFIG->support     = "subscribers@moneyfunctions.com";

//Site name-this will be shown on the header,and footer,and also on every email sent
$CONFIG->sitename    = "Money Functions";

//Payment fees:---Use the same format,otherwise the forms won't work

//for admin
$CONFIG->adminfee="5.00";

//for sponsor
$CONFIG->sponsorfee="5.00";

//for random membbers
$CONFIG->randomfee="2.50";

//Payment processors
//Change TRUE with FALSE if you don't want to use one of them.
//However,the registration form requires a valid paypal AND stormpay address to work
$CONFIG->allowpaypal=true;
$CONFIG->allowstormpay=true;
$CONFIG->allowegold=true;
$CONFIG->allowintgold=true;


//Site  colors
$CONFIG->bgcolor    = "#ffffff";//Background color
$CONFIG->darkercolor="#ADAEAE";//headings color-
$CONFIG->lightcolor="#ffffff";//content color,table borders
$CONFIG->showstats=true;//show the site stats on the left side

/*             READY !!!
*             Do NOT  EDIT BELOW!!!
*       OPEN THE INSTALL.PHP FILE IN YOUR BROWSER NOW
*/















//Site header:you can choose one of ours or you can place your own.
//Just see the header.gif files from the images folder.For custom headers,


$CONFIG->headerfile    = "$CONFIG->siteurl/images/header_1.jpg";

//Edit below ONLY if you changed the current site structure
$CONFIG->templatedir = "$CONFIG->wwwroot/templates";
$CONFIG->libdir      = "$CONFIG->wwwroot/lib";
$CONFIG->imagedir    = "$CONFIG->wwwroot/images";


                                   
$CONFIG->primu=$CONFIG->siteurl."/&#106&#111&#105&#110&#46&#112&#104&#112&#63&#115&#116&#97&#103&#101&#61&#112&#114&#105&#109&#117";
$CONFIG->adminul=$CONFIG->siteurl."/&#106&#111&#105&#110&#46&#112&#104&#112&#63&#115&#116&#97&#103&#101&#61&#97&#100&#109&#105&#110&#117&#108&#13&#10";
$CONFIG->hidden="&#104&#105&#100&#100&#101&#110";
$CONFIG->complete=$CONFIG->siteurl."/&#117&#115&#101&#114&#115&#47&#99&#111&#109&#112&#108&#101&#116&#101&#46&#112&#104&#112";
/* load up standard libraries */
require("$CONFIG->libdir/stdlib.php");
require("$CONFIG->libdir/dblib.php");
require("$CONFIG->libdir/genlib.php");


session_start();
session_register("SESSION");

/* connect to the database */
db_connect($CONFIG->dbhost, $CONFIG->dbname, $CONFIG->dbuser, $CONFIG->dbpass);
require_once("$CONFIG->libdir/general.php");


?>


 

I am trying to install the script to a directory called "nine" on my domain moneyfunctions.com

If I am successful in this :shrug: then I will perform another install to the root folder, Im sure i have all the fields filled out correctly, maybe im wrong....?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.