SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysqli_free_result Error

    Hi. I wanted to add a function to my site and do some work inside this function. But inside a function, i was unable to close the result set. Whenever i try to close, i get this error:

    mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in... etc

    here is my function:

    <?php
    function goster($a_id, $s_id, $mysqli)
    {
    define(MAX_LENGTH,200);

    echo $a_id." ".$s_id;
    $sql_ekle = "Update secenek
    set secenek.oy = secenek.oy +1
    where s_id = '$s_id'";


    $result_ekle = mysqli_query($mysqli, $sql_ekle);



    $sql_anket = "Select s_id, a_id, secenek, oy from secenek
    Where a_id='$a_id'";
    $result_secenek = mysqli_query($mysqli,$sql_anket);
    while($secenek = mysqli_fetch_assoc($result_secenek))
    {
    echo "{$secenek["secenek"]} {$secenek["oy"]}<br>";
    }

    mysqli_free_result($result_ekle);
    mysqli_free_result($result_secenek);

    }
    ?>

    Could anyone help me about this problem please?

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thats because some of your variables are not defined within your function.

    you can see which variables arent defined by turning up error reporting
    PHP Code:
    // top of script
    error_reporting(E_ALL); 
    have a read on variable scope
    http://www.php.net/manual/en/languag...bles.scope.php
    one of a few possible solutions is to use the "global" keyword.


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
  •