Fatal error: Call to undefined function script_check() ...

Discussion in 'PHP' started by CuBz, Jul 7, 2009.

  1. #1
    I am getting similar errors as the following error on my pages that contain a script check:

    Fatal error: Call to undefined function script_check() in /home/mlcbz/public_html/crime.php on line 8
    Code (markup):
    This is lines 6, 7 and 8 the script of crime.php:

    include_once"probe.php";
    $page="crime.php";
    script_check($page); 
    PHP:
    Here is the code for the script check (probe.php):

    <?php
    include_once("includes/db_connect.php");
    include_once("includes/functions.php");
    logincheck();
    echo"<link href=includes/in.css rel=stylesheet type=text/css>";
    
    $username=$_SESSION['username'];
    $fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));
    
    if ($fetch->last_script_check < time()){
    
    $eancol = rand(1,5);
    if($eancol == "1"){ $colour = "RED";
    }elseif($eancol == "2"){ $colour = "BLUE";
    }elseif($eancol == "3"){ $colour = "YELLOW";
    }elseif($eancol == "4"){ $colour = "GREEN";
    }elseif($eancol == "5"){ $colour = "ORANGE";
    }
    ?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <style type="text/css">
    <!--
    .style6 {color: #808080}
    -->
    </style>
    <head>
    <title>Untitled 1</title>
    <style type="text/css">
    .style3 {
    	text-align: center;
    	border: 1px solid #000000;
    	background-color: #808080;
    }
    .style4 {
    	text-align: center;
    	border: 1px solid #000000;
    	background-color: #666666;
    }
    .highlight {
    	text-align: center;
    	border: 1px solid #000000;
    	background-color: #CC0000;
    }
    .style5 {
    	font-size: 12px;
    	font-weight: bold;
    	color: $colour;
    }
    </style>
    </head>
    
    <body>
    <form method="post" action="">
      <table border="1" align="center" cellpadding="0" cellspacing="0" style="width: 50%">
    <tr>
    
    		<td height="21" colspan="4"  class=header class="style3"><center>Script Checker</td>
    	</tr>
    	<tr>
    		<td class="style4" colspan="4">Tick the radio box in <b><?php echo"<font color=$colour>$colour</font>";?></b></td>
    	</tr>
    	<tr>
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "1"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" class="style6" value="1" /></td>
    
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "2"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" value="2" /></td>
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "3"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" value="3" /></td>
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "4"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" value="4" /></td>
    	</tr>
    	<tr>
          <td align="center" bgcolor="<?php if($fetch->ver_code == "5"){ echo"$colour"; }else{ echo"#808080"; }?>"  style="width: 25%; height: 38px"><input name="radio" type="radio" value="5" /></td>
    	  <td align="center" bgcolor="<?php if($fetch->ver_code == "6"){ echo"$colour"; }else{ echo"#808080"; }?>"  style="width: 25%; height: 38px"><input name="radio" type="radio" value="6" /></td>
    	  <td align="center" bgcolor="<?php if($fetch->ver_code == "7"){ echo"$colour"; }else{ echo"#808080"; }?>"  style="width: 25%; height: 38px"><input name="radio" type="radio" value="7" /></td>
    	  <td align="center" bgcolor="<?php if($fetch->ver_code == "8"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" value="8" /></td>
        </tr>
    	<tr>
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "9"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" value="9" /></td>
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "10"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" value="10" /></td>
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "11"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio" type="radio" value="11" /></td>
    		<td align="center" bgcolor="<?php if($fetch->ver_code == "12"){ echo"$colour"; }else{ echo"#808080"; }?>" style="width: 25%; height: 38px"><input name="radio"  type="radio" value="12" /></td>
    	</tr>
    	<tr>
    		<td height="35" colspan="4" class="style3"><input type="submit" name="submit" class="custombutton" value="Script Check">
    		  <br />
              <?php
    if($_POST['submit'] && $_POST['radio']){
    $radio=$_POST['radio'];
    if($radio != $fetch->ver_code){
    $randy = rand(1,12);
    if($randy == $radio){
    $newone = $radio + 1;}elseif($randy != $radio){ $newone = $randy;}
    if($newone > "12"){ $newone = "11"; }
    mysql_query("UPDATE users SET ver_code='$newone' WHERE username='$username'");
    echo"Wrong box!"; echo"<META http-equiv=\"refresh\" content=\"1;URL=probe.php\">";
    }else{
    $time=time()+(60*9);
    $randy = rand(1,12);
    if($randy == $radio){
    $newone = $radio + 1;}elseif($randy != $radio){ $newone = $randy;}
    if($newone > "12"){ $newone = "11"; } 
    mysql_query("UPDATE users SET last_script_check='$time', ver_code='$newone' WHERE username='$username'");
    echo "Correct code!";
    echo"
    <SCRIPT LANGUAGE='JavaScript'>
    history.go(-1)
    </script>";
    }
    }
    
    ?>          <br />        </td>
    	</tr>
    </table>
    </form>
    
    
    
    <?php 
    function script_check($file){
    }?>
    </body>
    
    </html>
    <?php
    exit();
    } ?>
    PHP:
    It is basically a script check that asks you to select the correct coloured box.

    What is the problem?

    Thanks for your help
     
    CuBz, Jul 7, 2009 IP
  2. xrvel

    xrvel Notable Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    225
    #2
    Main problem is the script can not find "script_check()" function.
    Probably it was on "includes/functions.php"
    To do some test, run this
    include_once"probe.php";
    $page="crime.php";
    var_dump(function_exists('script_check'));
    script_check($page);
    
    PHP:
    Probably it will return "false" instead of "true".
    Try to replace "include" with "require", let's see if some path is broken.
     
    xrvel, Jul 7, 2009 IP
  3. CuBz

    CuBz Peon

    Messages:
    117
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have tried that but i returned false and so did 'require'
     
    CuBz, Jul 7, 2009 IP
  4. xrvel

    xrvel Notable Member

    Messages:
    918
    Likes Received:
    30
    Best Answers:
    2
    Trophy Points:
    225
    #4
    So the script does not recognize that function.

    So how do you get this script?
    There could be an explanation that there were a function there, but accidentally it was missing (could be deleted, replaced, deprecated etc)
    Probably you can ask the developer (previous programmer -- if you don't code it by yourself).

    Edit :
    Note that on "probe.php", i noticed these
    <?php 
    function script_check($file){
    }?>
    PHP:
    So actually the function does exist.
    But somehow there is nothing to do there.
    Looks like an empty function.
    Probably the "script_check" function has been modified & "deprecated" somehow.

    So i guess you can comment this line safely.
    
    include_once"probe.php";
    $page="crime.php";
    //script_check($page);
    
    PHP:
     
    xrvel, Jul 7, 2009 IP
  5. CuBz

    CuBz Peon

    Messages:
    117
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    me and my brother coded it but i havn't done coding in quite a while, and i coded these pages 4 years ago lol its al just drained out of me lol

    Anyway thanks alot worked a treat
     
    CuBz, Jul 7, 2009 IP