当前位置: 动力学知识库 > 问答 > 编程问答 >

Fatal error: Call to a member function return_module_option() on string in C:\xampp\htdocs\ges\ges-admin\application_list.php on line 107

问题描述:

This is my code

require "../ges-admin/class/modules.php";

$module = new modules();

echo $module->return_module_option("");

Page:application_list.php

This is my class code:

class modules {

private function get_module($selid){

$getconn = new dbconnect();

$conn = $getconn->getconn();

$sel_module = mysqli_query($conn,"SELECT * FROM `ielts_module` WHERE `status`='1'");

while($fetch_module = mysqli_fetch_assoc($sel_module))

{

?>

<option <?php if($selid==$fetch_module['id']){ echo "selected=selected"; }?> value="<?php echo $fetch_module['id']; ?>"><?php echo $fetch_module['modules']; ?></option>

<?php

}

}

private function module_name($mid){

$getconn = new dbconnect();

$conn = $getconn->getconn();

$sel_module = mysqli_query($conn,"SELECT `modules` FROM `ielts_module` WHERE `id`='$mid'");

$fetch_module = mysqli_fetch_assoc($sel_module);

return $fetch_module['modules'];

}

public function return_module_option($selid){

return $this->get_module($selid);

}

public function get_module_name($mid)

{

return $this->module_name($mid);

}

}

This echo $module->return_module_option(""); code is works fine when page loads after submitting the form through get method, it shows

Fatal error: Call to a member function return_module_option() on string in C:\xampp\htdocs\ges\ges-admin\application_list.php on line 107

网友答案:

You need to confirm what new modules() is returning. Try outputting $module across both the GET and POST requests for the route. Then correct the reason why new modules() isn't returning the correct return type.

var_dump($modules);

Also, if you can share your modules class that'd be a start, or at least the constructor.

分享给朋友:
您可能感兴趣的文章:
随机阅读: