0

ive got 2 dropdown menu that retrieve the file from the database. but it gives me an error when im trying to get the the 2nd file.

The first dropdown, successfully retrieved but the second one gives me an error?

in PHP class

class treatment{
function __construct($mysqli){}

// Get treatment list
function get_t_dermal_filler(){
    global $mysqli;
    $q = $mysqli->query("SELECT * FROM t_dermal_filler ORDER BY t_dermal_name ASC");
    while ($r = $q->fetch_array(MYSQLI_ASSOC)) :    
        echo '<option value="' . $r['id_t_dermal_filler'] . '" >' . $r['t_dermal_name'] . '</option>';  
    endwhile;

    $mysqli->close();   
}

// Get treatment list
function get_t_wrinkle_rel(){   
    global $mysqli;
    $q = $mysqli->query("SELECT * FROM t_wrinkle_rel");     
    while ($r = $q->fetch_array(MYSQLI_ASSOC)) :    
        echo '<option value="' . $r['id_t_wrinkle_rel'] . '" >' . $r['t_wrinkle_name'] . '</option>';   
    endwhile;           
    $mysqli->close();   
}
 }

in webpage

$treatment = new treatment($mysqli);
<?= $treatment->get_t_dermal_filler();?>
<?= $treatment->get_t_wrinkle_rel();?>

the error

 <b>Warning</b>:  mysqli::query() [<a href='mysqli.query'>mysqli.query</a>]: Couldn't fetch mysqli in <b>
1
  • Not sure we have enough information. Was there anymore to that error? It seems truncated. Commented Jan 6, 2011 at 15:07

1 Answer 1

1

I think the problem is the closing of the mysqli

remove them from both functions, and then after asking for all the data, close it.

Sign up to request clarification or add additional context in comments.

1 Comment

you're welcome, and I agree, global makes me want to scratch my eyes out

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.