SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Call to undefined function insert()..Help anyone

    this is my code..is there any error in my logic

    Code PHP:
    <?php
    session_start();
    include_once("conn.php");
    $ass=mssql_query("Select * from tblAssign where TicketNo='$_SESSION[tick]' and AssignTo='$_SESSION[username]'");
    $count = mssql_num_rows($ass);
    if ($count < 1) {
    insert($_SESSION[tick],$_POST['msg'],$_SESSION[username],$_POST['pic'],$_POST['status'],$_SESSION[name],$con);
    header('location:supportreport.php');
    function insert($tick,$msg,$AssngTo,$pic,$status,$createby,$con){
    mssql_query("sp_assign @tick='$tick',@uname='$AssngTo',@pic='$pic',@stat='$status',@Create='$createby'");
    mssql_query("sp_post @tick='$tick',@msgby='$AssngTo',@msg='$msg'");
    	mssql_close($con);
    }
     
    }
    else{
    insert($_SESSION[tick],$_POST['msg'],$_SESSION[username],$con);
    header('location:supportreport.php');
    function insert($tick,$msg,$AssngTo,$con){
    mssql_query("sp_post @tick='$tick',@msgby='$AssngTo',@msg='$msg'");
    mssql_close($con);
    }
    }
    ?>

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Maybe because you are calling insert() before you have described it?

    Off Topic:

    $ass?

  3. #3
    Non-Member
    Join Date
    Apr 2004
    Location
    Miami, FL, USA
    Posts
    449
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ^^ Not to mention you're defining your function twice... and inside an if..then statement. Try this:
    Code php:
    <?php
    session_start();
    include_once("conn.php");
     
    function insertAss1($tick,$msg,$AssngTo,$pic,$status,$createby,$con){
        mssql_query("sp_assign @tick='$tick',@uname='$AssngTo',@pic='$pic',@stat='$status',@Create='$createby'");
        mssql_query("sp_post @tick='$tick',@msgby='$AssngTo',@msg='$msg'");
        mssql_close($con);
    }
     
    function insertAss2($tick,$msg,$AssngTo,$con){
        mssql_query("sp_post @tick='$tick',@msgby='$AssngTo',@msg='$msg'");
        mssql_close($con);
    }
     
    function countAsses() {
        $ass=mssql_query("Select * from tblAssign where TicketNo='$_SESSION[tick]' and AssignTo='$_SESSION[username]'");
        return mssql_num_rows($ass);
    }
     
    if (countAsses() < 1) {
        insertAss1($_SESSION[tick],$_POST['msg'],$_SESSION[username],$_POST['pic'],$_POST['status'],$_SESSION[name],$con);
        header('location:supportreport.php'); 
    }
    else{
        insertAss2($_SESSION[tick],$_POST['msg'],$_SESSION[username],$con);
        header('location:supportreport.php');
    }
    ?>

  4. #4
    SitePoint Zealot
    Join Date
    Mar 2011
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Steve it works..


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •