#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    2
    Rep Power
    0
    I am currently butting my head against a brick wall with a problem right now. I am trying to use two arrays to track an item and it's quantity. When ever the script runs it says I keep getting this error message:

    Fatal error: Call to undefined function: () in /info/www/docs/cpcdb/search/addcart.php on line 109

    This error occurs on the first time the session is initialized. The called function is get(). When I reload the page (reloading session) I get a new error

    Fatal error: Call to undefined function: () in /info/www/docs/cpcdb/search/addcart.php on line 93

    which occurs in a branch of an if statement that checks to see if my arrays are not empty. The function called on line 93 is upditem.

    What follows is the code for the page...

    <?php
    session_start();
    //----------------shopping cart handler----------------//

    if(!($modelnum and $counter)){
    $modelnum=array();
    $counter=array();
    session_register("modelnum");
    session_register("counter");
    }

    //check for irregular input
    if (!$modnum)
    die("No Model Number passed.");
    if (!$count)
    die ("No purchase volume given.");

    //-------------Begin Function Definitions-------------//
    function additem($mod,$cnt){
    global $modelnum, $counter;
    array_push($modelnum,$mod);
    array_push($counter,$cnt);
    }

    function upditem($model,$cnt){
    global $modelnum, $counter;
    $tmpm=$modelnum;
    $tmpc=$counter;
    $index=sizeof($tmpm);
    for($i=0;$i<$index;$i++){
    $model=array_pop($tmpm);
    $count=array_pop($tmpc);
    echo "$model $countn";
    if ($model=$mod){
    $counter[$i]=$counter[$i]+$cnt;
    return true;
    }
    }
    return false;
    }

    function isitem($mod){
    global $modelnum, $counter;
    $tmpm=$modelnum;
    $tmpc=$counter;
    $index=sizeof($tmpm);
    for($i=0;$i<$index;$i++){
    $model=array_pop($tmpm);
    $count=array_pop($tmpc);
    if ($model=$mod){
    return true;
    }
    }
    return false;
    }

    //destructive function
    function get($mod){
    print "Got into getmn";
    return array(array_pop($mod));
    }

    function isempty(){
    global $modelnum, $counter;
    $index=sizeof($modelnum);
    if ($index<=0)
    return true;
    return false;
    }

    //---------------End Function Definitions-------------------//

    if (!isitem($modnum)){
    additem($modnum,$count);
    echo "modified new cartn";
    }else{
    $upditem($modnum,$count);
    echo "modified old cartn";
    }

    //db link setup

    $tmpm=$modelnum;
    $tmpc=$counter;
    while(!isempty()){
    $modnum=$get($tmpm);
    $count=$get($tmpc);
    $sql = "SELECT * FROM $dbtable WHERE modelnum='$modnum'";
    $result = mysql_db_query($dbname,$sql);
    $value = mysql_fetch_array($result);
    print "<TR>";
    print "<TD BGCOLOR='#A7A7A7' VALIGN='MIDDLE' ALIGN='CENTER'> $value[0] </TD>";
    print "<TD BGCOLOR='#A7A7A7' VALIGN='MIDDLE' ALIGN='CENTER'> $value[1] </TD>";
    print "<TD BGCOLOR='#A7A7A7' VALIGN='MIDDLE' ALIGN='CENTER'> $value[2] </TD>";
    print "<TD BGCOLOR='#A7A7A7' VALIGN='MIDDLE' ALIGN='CENTER'> $value[3] </TD>";
    print "<TD BGCOLOR='#A7A7A7' ALIGN='RIGHT'>";
    print "<FORM><INPUT TYPE='TEXT' NAME='count' SIZE='4' MAXLENGTH='4' VALUE='$count'>";
    print "<INPUT TYPE='SUBMIT' NAME='Submit1' VALUE='Add Items' CHECKED='CHECKED'>";
    print "<input type='HIDDEN' NAME='modnum' VALUE='$modnum'></FORM></TD>";
    print "</TR>n";
    }
    ?>
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    2
    Rep Power
    0
    How to make your self feel like a dumbass... put a '$' infront of your function calls. Problem solved

Similar Threads

  1. Replies: 1
    Last Post: January 28th, 2004, 04:35 PM

IMN logo majestic logo threadwatch logo seochat tools logo