Toddb1 Posted June 8, 2009 Share Posted June 8, 2009 I get an error when this cron is executed <? include("funcs.php"); $getgames = mysql_query("SELECT round FROM $tab[game] WHERE starts<$time AND ends>$time ORDER BY round ASC;"); while ($game = mysql_fetch_array($getgames)) { if (!fetch("SELECT lastran FROM r$game[0]_$tab[cron] WHERE cronjob='cranks';")) { mysql_query("INSERT INTO r$game[0]_$tab[cron] VALUES ('cranks','$time');"); } else { mysql_query("UPDATE r$game[0]_$tab[cron] SET lastran='$time' WHERE cronjob='cranks'"); } mysql_query("UPDATE r$game[0]_$tab[pimp] SET attin=attin-1 WHERE attin<=10;"); mysql_query("UPDATE r$game[0]_$tab[pimp] SET attin='9' WHERE attin>10;"); $getcrewranks = mysql_query("SELECT id FROM r$game[0]_$tab[crew] WHERE id>0 ORDER BY networth DESC;"); $urank = 0; while ($crws = mysql_fetch_array($getcrewranks)) { $urank++; mysql_query("UPDATE r$game[0]_$tab[crew] SET rank=$urank WHERE id='$crws[0]';"); } } ?> the error I get in my e-mail is % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 151 0 151 0 0 1820 0 --:--:-- --:--:-- --:--:-- 1820 100 151 0 151 0 0 1758 0 --:--:-- --:--:-- --:--:-- 0 <br /> <b>Fatal error</b>: Call to undefined function fetch() in <b>/home/fbcgoodr/public_html/SCARLITOSWAY.COM/setup.php</b> on line <b>77</b><br /> here is the setup file where the error is occurring <? include("conn.php"); //////Main Settings $result = mysql_query("Select * From settings",$connect); $row = mysql_fetch_array($result, MYSQL_BOTH); $sitename = $row['sitename']; $adminemail = $row['adminemail']; $adminpaypal = $row['adminpaypal']; $fullurl = $row['fullurl']; $domain = $row['domain']; $refpercent = $row['refpercent']; $refcredits = $row['refcredits']; $withdrawturns = $row['withdrawturns']; $depositturns = $row['depositturns']; $jackpotper = $row['jackpotper']; $crewbanktoggle = $row['cbank']; //Installation Check if (file_exists("install/index.php")) { echo "<html><body><script language=javascript1.1>alert('Please delete the Install dir!');</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>"; exit; } //Good ol' time $time=time(); //////UPLOAD SETTINGS $dir="../images/icons/$tru/"; $arr_allow_ex=array("gif","jpg","png"); $maxupload[sup] = '20000'; //supporter upload in bytes $maxupload[nor] = '15000'; //normal upload in bytes //////PRETTY SIMPLE, MAKE SURE URL LOCATIONS END WITH "/" $site[location] = $fullurl; ///SITE LOCATION $site[img] = '/images/'; ///SITE IMAGES //////DATABASE TABLES $tab[user] = 'users'; $tab[html] = 'html'; $tab[news] = 'news'; $tab[game] = 'games'; $tab[stat] = 'stats'; $tab[censor] = 'censors'; $tab[banned] = 'bans'; $tab[paypal] = 'paypal'; $tab[logs] = 'logs'; $tab[bannedip] = 'banned'; $tab[contracts] = 'contracts'; $tab[credits] = 'credits'; /////GAME DATABASE TABLES $tab[board] = "board"; $tab[clist] = "contacts"; $tab[city] = "city"; $tab[crew] = "crew"; $tab[crewr] = "crewr"; $tab[invite] = "invites"; $tab[mail] = "mailbox"; $tab[pimp] = "pimp"; $tab[revenge] = "revenges"; $tab[cron] = "cronjobs"; $tab[bank] = "bank"; $tab[forum_post] = "forum_post"; $tab[forum_postext] = "forum_postext"; $tab[forum_smile] = "forum_smile"; $tab[forum_topic] = "forum_topic"; $tab[market] = "blackmarket"; //Ban Check $userip=$_SERVER["REMOTE_ADDR"]; if (fetch("Select * from $tab[bannedip] where ip = '$userip';")) { echo "<html><body><script language=javascript1.1>alert('Your IP Address Was Banned!');</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>"; exit; } if(($tru) && (!mysql_fetch_row(mysql_query("SELECT round FROM $tab[game] WHERE round='$tru' AND starts<$time AND ends>$time;")))) { header("Location: $site[location]play.php"); } if($tru){ $tab[board] = "r".$tru."_board"; $tab[clist] = "r".$tru."_contacts"; $tab[city] = "r".$tru."_city"; $tab[crew] = "r".$tru."_crew"; $tab[crewr] = "r".$tru."_crewr"; $tab[invite] = "r".$tru."_invites"; $tab[mail] = "r".$tru."_mailbox"; $tab[pimp] = "r".$tru."_$tab[pimp]"; $tab[revenge] = "r".$tru."_revenges"; $tab[cron] = "r".$tru."_cronjobs"; $tab[bank] = "r".$tru."_bank"; $tab[forum_post] = "r".$tru."_forum_post"; $tab[forum_postext] = "r".$tru."_forum_postext"; $tab[forum_smile] = "r".$tru."_forum_smile"; $tab[forum_topic] = "r".$tru."_forum_topic"; $tab[market] = "r".$tru."_blackmarket"; $tab[playervotes] = "r".$tru."_playervotes"; } //////CENSORS $getcensors = mysql_query("SELECT censor FROM $tab[censor];"); $censorwords = array(); while($censor=mysql_fetch_array($getcensors)) { array_push($censorwords, $censor[0]); } $id2 = mysql_fetch_array(mysql_query("SELECT id FROM $tab[user] WHERE code='$trupimpn';")); $id1=$id2[0]; //GRAB THEY MASTER AND GAME ID if($tru){ $id = mysql_fetch_array(mysql_query("SELECT id FROM $tab[pimp] WHERE code='$trupimpn';")); } else{ $id = mysql_fetch_array(mysql_query("SELECT id FROM $tab[user] WHERE code='$trupimp';")); } $id=$id[0]; //Jackpot Calculator $paypal = mysql_fetch_row(mysql_query("SELECT sum(amount), sum(fee) FROM $tab[paypal];")); $totalprofit=($paypal[0]-$paypal[1])/1; $jackpot = ($totalprofit*($jackpotper/100)); $forum_title = "Pimp Forums"; $itemperpage = 10; $tablewidth = 620; //minimum value is 600 $maxchar = 2000; //maximum character for every posting to avoid flooding $headercolor = "#999999"; $rowcolor1 = "#e5e5e5"; $rowcolor2 = "#f0f0f0"; $admheadercolor = "#999999"; $admrowcolor1 = "#e5e5e5"; $admrowcolor2 = "#f0f0f0"; ?> the line in question is in the "//ban check" section the exact line is this one if (fetch("Select * from $tab[bannedip] where ip = '$userip';")) can someone help me figure out what the problem is and why it will not run this cron I know it will be simple but I just cant figure it out Quote Link to comment Share on other sites More sharing options...
Adam Posted June 8, 2009 Share Posted June 8, 2009 It tells you the problem: 'Call to undefined function fetch()' ? Looks like a custom database function to query a database and return the rows. Are you sure the function is included into your code? It's not in any of the code you supplied, what's in "funcs.php"? Quote Link to comment Share on other sites More sharing options...
Toddb1 Posted June 8, 2009 Author Share Posted June 8, 2009 It tells you the problem: 'Call to undefined function fetch()' ? Looks like a custom database function to query a database and return the rows. Are you sure the function is included into your code? It's not in any of the code you supplied, what's in "funcs.php"? I did not incluse the func.php because I thought the error was said to be in Call to undefined function fetch() in <b>/home/fbcgoodr/public_html/SCARLITOSWAY.COM/setup.php</b> on line <b>77</b><br /> I dont know much about PHP so if I say something stupid please forgive me here is the func.php you asked for <? include("setup.php"); function commas ($str){ return number_format(floor($str)); } function mail_1 ($subject, $message, $email){ global $adminemail; mail("$email", "$subject", $message, "From: $adminemail\r\n" ."Reply-To: $adminemail\r\n" ."X-Mailer: PHP/" . phpversion()); } function dayhour ($online){ global $time; $difference=$online-$time; $num = $difference/86400; $days = intval($num); $num2 = ($num - $days)*24; $hours = intval($num2); if($days != 0){echo"$days days, ";}if($hours != 0){echo"$hours hours. ";} } function countdown ($online){ global $time; $difference=$online-$time; $num = $difference/86400; $days = intval($num); $num2 = ($num - $days)*24; $hours = intval($num2); $num3 = ($num2 - $hours)*60; $mins = intval($num3); $num4 = ($num3 - $mins)*60; $secs = intval($num4); if($days != 0){echo"$days days, ";} if($hours != 0){echo"$hours hours, ";} if($mins != 0){echo"$mins mins, ";} if($secs != 0){echo"$secs secs. ";} } function securepic( $var ){ if(strstr($var,"diamondswebpages")) {$var="gfx/media/banned.gif";} elseif(strstr($var,"http://mywebpages.comcast.net/wahtever/")) {$var="gfx/media/banned.gif";} elseif(strstr($var,"http://thunder.prohosting.com/~csears/WeBmAsTeR.swf")) {$var="gfx/media/banned.gif";} elseif(strstr($var,"http://www.rentyman.com/temp/rentyman.swf")) {$var="gfx/media/banned.gif";} elseif(strstr($var,"http://www.millsracing.com/images/fatguyeating.gif")) {$var="gfx/media/banned.gif";} elseif(strstr($var,"http://www.redcoat.net/pics/tubgirl.jpg")) {$var="gfx/media/banned.gif";} elseif(strstr($var,"pimpwarhelp.com")) {$var="gfx/media/banned.gif";} else{$var=$var;} return $var; } ?> thanks for the quick response Quote Link to comment Share on other sites More sharing options...
jxrd Posted June 8, 2009 Share Posted June 8, 2009 So where is fetch being defined? Quote Link to comment Share on other sites More sharing options...
Adam Posted June 8, 2009 Share Posted June 8, 2009 Yeah as jxrd was getting at fetch() isn't defined anywhere, so when you tried to call it in setup.php on line 77 it wasn't found and triggered the error there. Is this re-used code? Quote Link to comment Share on other sites More sharing options...
Toddb1 Posted June 8, 2009 Author Share Posted June 8, 2009 So where is fetch being defined? Sorry I don't know I was hoping someone could tell me how to fix the problem Quote Link to comment Share on other sites More sharing options...
jxrd Posted June 8, 2009 Share Posted June 8, 2009 Yeah, you can't use a function if it doesn't exist. It's just logic. Did you write this code yourself? Quote Link to comment Share on other sites More sharing options...
Toddb1 Posted June 8, 2009 Author Share Posted June 8, 2009 Yeah as jxrd was getting at fetch() isn't defined anywhere, so when you tried to call it in setup.php on line 77 it wasn't found and triggered the error there. Is this re-used code? yes it is reused I got this game from a friend because he could not get the crons working right either. so if the fetch() is not being defined how would I go about writing that into my "cron.php file to eliminate the error or could I just eliminate the line in question all together. Quote Link to comment Share on other sites More sharing options...
Adam Posted June 8, 2009 Share Posted June 8, 2009 What's in "conn.php"? You'll need to either re-write the fetch() function, or change it to a normal query: $check_ip = mysql_query("Select * from $tab[bannedip] where ip = '$userip'"); if (mysql_num_rows($check_ip) > 0) { echo "<html><body><script language=javascript1.1>alert('Your IP Address Was Banned!');</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>"; exit; } Quote Link to comment Share on other sites More sharing options...
MadTechie Posted June 8, 2009 Share Posted June 8, 2009 Who knows,, try adding this function fetch($SQL) { if(empty($SQL)) return false; $result = mysql_query($SQL); return (bool)(mysql_num_rows($result)>0); } Quote Link to comment Share on other sites More sharing options...
Toddb1 Posted June 8, 2009 Author Share Posted June 8, 2009 What's in "conn.php"? You'll need to either re-write the fetch() function, or change it to a normal query: $check_ip = mysql_query("Select * from $tab[bannedip] where ip = '$userip'"); if (mysql_num_rows($check_ip) > 0) { echo "<html><body><script language=javascript1.1>alert('Your IP Address Was Banned!');</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>"; exit; } I put that code in and now the error I get is <br /> <b>Fatal error</b>: Call to undefined function fetch() in <b>/home/fbcgoodr/public_html/SCARLITOSWAY.COM/1crewcron.php</b> on line <b>7</b><br /> which is this line of code if (!fetch("SELECT lastran FROM r$game[0]_$tab[cron] WHERE cronjob='cranks';")) so it appears to me the fetch() is being defined from there conn.php is just my database connection info Quote Link to comment Share on other sites More sharing options...
Toddb1 Posted June 8, 2009 Author Share Posted June 8, 2009 Who knows,, try adding this function fetch($SQL) { if(empty($SQL)) return false; $result = mysql_query($SQL); return (bool)(mysql_num_rows($result)>0); } would I add that to the "cron.php" or to the "setup.php" file lol Quote Link to comment Share on other sites More sharing options...
Adam Posted June 8, 2009 Share Posted June 8, 2009 $check_ip = mysql_query("Select * from $tab[bannedip] where ip = '$userip'"); if (mysql_num_rows($check_ip) > 0) { echo "<html><body><script language=javascript1.1>alert('Your IP Address Was Banned!');</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>"; exit; } Was meant to be a swap for: if (fetch("Select * from $tab[bannedip] where ip = '$userip';")) { echo "<html><body><script language=javascript1.1>alert('Your IP Address Was Banned!');</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>"; exit; } Quote Link to comment Share on other sites More sharing options...
MadTechie Posted June 8, 2009 Share Posted June 8, 2009 Erm... setup.php Quote Link to comment Share on other sites More sharing options...
Toddb1 Posted June 8, 2009 Author Share Posted June 8, 2009 $check_ip = mysql_query("Select * from $tab[bannedip] where ip = '$userip'"); if (mysql_num_rows($check_ip) > 0) { echo "<html><body><script language=javascript1.1>alert('Your IP Address Was Banned!');</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>"; exit; } Was meant to be a swap for: if (fetch("Select * from $tab[bannedip] where ip = '$userip';")) { echo "<html><body><script language=javascript1.1>alert('Your IP Address Was Banned!');</script><noscript>Your browser doesn't support JavaScript 1.1 or it's turned off in your browsers preferences.</noscript></body></html>"; exit; } it was swapped for that and then got the above mentioned error on line 7 Quote Link to comment Share on other sites More sharing options...
jxrd Posted June 8, 2009 Share Posted June 8, 2009 You use the function twice. Quote Link to comment Share on other sites More sharing options...
Adam Posted June 8, 2009 Share Posted June 8, 2009 There's multiple references to fetch(); just add MadTechie's function to avoid any confusion. Quote Link to comment Share on other sites More sharing options...
Toddb1 Posted June 8, 2009 Author Share Posted June 8, 2009 There's multiple references to fetch(); just add MadTechie's function to avoid any confusion. lol I just have to laugh because if I dont I get to frustrated when I use MadTechie's fuction I get an error on my other cron job that is running here is the new error <b>Fatal error</b>: Cannot redeclare fetch() (previously declared in /home/fbcgoodr/public_html/SCARLITOSWAY.COM/10mins5.php:3) in <b>/home/fbcgoodr/public_html/SCARLITOSWAY.COM/setup.php</b> on line <b>81</b><br /> this is line 76-81 function fetch($SQL) { if(empty($SQL)) return false; $result = mysql_query($SQL); return (bool)(mysql_num_rows($result)>0); } Quote Link to comment Share on other sites More sharing options...
Adam Posted June 8, 2009 Share Posted June 8, 2009 I imagine it's something to do with having the function twice? Try searching through all the related files for "function fetch(" (no quotes) and locating which file fetch() was originally stored in, then include it! Probably what's happening is your putting it in setup.php, but another script uses that too which does include fetch, and so gives an error. If that makes sense? Quote Link to comment Share on other sites More sharing options...
MadTechie Posted June 8, 2009 Share Posted June 8, 2009 Look at the cron that fails and look at the includes.. one of those likely has the fetch function or maybe try if (!function_exists('fetch')) { function fetch($SQL) { if(empty($SQL)) return false; $result = mysql_query($SQL); return (bool)(mysql_num_rows($result)>0); } } Quote Link to comment Share on other sites More sharing options...
Toddb1 Posted June 8, 2009 Author Share Posted June 8, 2009 Look at the cron that fails and look at the includes.. one of those likely has the fetch function or maybe try if (!function_exists('fetch')) { function fetch($SQL) { if(empty($SQL)) return false; $result = mysql_query($SQL); return (bool)(mysql_num_rows($result)>0); } } this worked thank you all for your help I would have never figured it out by myself Quote Link to comment Share on other sites More sharing options...
MadTechie Posted June 8, 2009 Share Posted June 8, 2009 I would still recommend you checking the other script and including the one with the correct funtion,, either that or add a comment saying this is a workaround or something If solved please click solved! Quote Link to comment Share on other sites More sharing options...
jxrd Posted June 8, 2009 Share Posted June 8, 2009 You might be including the file ina loop. In which case you can just use include_once(). Or...just include it once Quote Link to comment Share on other sites More sharing options...
Toddb1 Posted June 8, 2009 Author Share Posted June 8, 2009 I would still recommend you checking the other script and including the one with the correct funtion,, either that or add a comment saying this is a workaround or something If solved please click solved! I will check the rest of the script and related files and search for the original fetch() and try to fix it that way but either this way or through another this problem is fixed I know you cant see me but I am bowing down before you at my computer Thank you! Quote Link to comment Share on other sites More sharing options...
MadTechie Posted June 8, 2009 Share Posted June 8, 2009 fghmj ghsxbmvm, OUCH! just bowed back and smacked my head on the keyboard! Quote Link to comment 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.