teamfresh Posted October 21, 2009 Share Posted October 21, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/ Share on other sites More sharing options...
Mchl Posted October 21, 2009 Share Posted October 21, 2009 You should contact script authors about that. db_connect is not a default PHP function, so it seems there might be some bug in the script. Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941176 Share on other sites More sharing options...
teamfresh Posted October 21, 2009 Author Share Posted October 21, 2009 I can not contact the author. Its one of the first things I tried when the problem arose have but no reply. Is there any way to get rid of the bug? Should I post my config.php here for you guys to look at? Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941188 Share on other sites More sharing options...
Mchl Posted October 21, 2009 Share Posted October 21, 2009 Tough luck then. You have to try to find out in which file db_connect() function is defined, and then require it into your config.php This might work, or might not, depending on what else is missing. Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941193 Share on other sites More sharing options...
teamfresh Posted October 21, 2009 Author Share Posted October 21, 2009 ok thanks for the quick reply, I will have a look and see if I can find where the function is. Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941196 Share on other sites More sharing options...
teamfresh Posted October 21, 2009 Author Share Posted October 21, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941207 Share on other sites More sharing options...
Mchl Posted October 21, 2009 Share Posted October 21, 2009 Try putting require('lib/dblib.php'); somewhere at the beginning of your config.php Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941212 Share on other sites More sharing options...
teamfresh Posted October 21, 2009 Author Share Posted October 21, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941226 Share on other sites More sharing options...
Mchl Posted October 21, 2009 Share Posted October 21, 2009 ok... We might be on to something... Can you find where $CONFIG variable is declared? Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941247 Share on other sites More sharing options...
teamfresh Posted October 21, 2009 Author Share Posted October 21, 2009 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 */ Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941259 Share on other sites More sharing options...
teamfresh Posted October 21, 2009 Author Share Posted October 21, 2009 sorry- im looking for function right? Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941261 Share on other sites More sharing options...
teamfresh Posted October 21, 2009 Author Share Posted October 21, 2009 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())");} ?> Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941272 Share on other sites More sharing options...
teamfresh Posted October 21, 2009 Author Share Posted October 21, 2009 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."/join.php?stage=primu"; $CONFIG->adminul=$CONFIG->siteurl."/join.php?stage=adminul
"; $CONFIG->hidden="hidden"; $CONFIG->complete=$CONFIG->siteurl."/users/complete.php"; /* 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 Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941284 Share on other sites More sharing options...
Mchl Posted October 21, 2009 Share Posted October 21, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941299 Share on other sites More sharing options...
teamfresh Posted October 21, 2009 Author Share Posted October 21, 2009 when you say change them by hand, how would i go about that? Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941320 Share on other sites More sharing options...
Mchl Posted October 21, 2009 Share Posted October 21, 2009 Fill in database user/password data with those that match yours. Set wwwroot to your actual root directory etc... Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941345 Share on other sites More sharing options...
teamfresh Posted October 21, 2009 Author Share Posted October 21, 2009 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."/join.php?stage=primu"; $CONFIG->adminul=$CONFIG->siteurl."/join.php?stage=adminul
"; $CONFIG->hidden="hidden"; $CONFIG->complete=$CONFIG->siteurl."/users/complete.php"; /* 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 then I will perform another install to the root folder, Im sure i have all the fields filled out correctly, maybe im wrong....? Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941357 Share on other sites More sharing options...
Mchl Posted October 21, 2009 Share Posted October 21, 2009 I am pretty sure you should have someting else in $CONFIG->wwwroot Ask your hosting provider for 'webroot' directory. Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941368 Share on other sites More sharing options...
teamfresh Posted October 21, 2009 Author Share Posted October 21, 2009 Yes! You were right. Thank you thank you thank you! I really appreciate your patience in helping me with this. I was so close to giving up but now its all working like a dream. Thank you once again wooo wooo Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941398 Share on other sites More sharing options...
teamfresh Posted October 21, 2009 Author Share Posted October 21, 2009 If there is any thing i can do to say thanks, just say the word. You are welcome to free advertising on my other website http://www.hd-fractals.com In the side bar and/or a post/review with links etc. Just let me know. Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941403 Share on other sites More sharing options...
Mchl Posted October 21, 2009 Share Posted October 21, 2009 You can always put a link to phpfreaks there. Or visit this thread: http://www.phpfreaks.com/forums/index.php/topic,45685.0.html P.S. If you didn't so far, remove the require we did as the first fix. Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941414 Share on other sites More sharing options...
teamfresh Posted October 21, 2009 Author Share Posted October 21, 2009 yeah I have removed it. I will place the links. thanks once again, I will definitely donate once i have some money, next week some time. If i had any money atm I would have prob just brought a different script!!! Quote Link to comment https://forums.phpfreaks.com/topic/178479-solved-call-to-undefined-function-db_connect/#findComment-941430 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.