Yohanne Posted March 19, 2013 Share Posted March 19, 2013 (edited) hi all, why i got this error Fatal error: Can't use method return value in write context in? in line 14 error <?php class item_controller { public function set_safe($value) { return mysql_real_escape_string($value); } public function check_first() { $func_array = array(); if(isset($_POST['new']) && 'Add' == $_POST['new']) { if(empty($this->set_safe($_POST['categoryname']))); { $func_array[] = 'invalid value, category'; } else { $this->set_safe($_POST['categoryname']) = stripslashes($this->get_safe($_POST['categoryname'])); } if(empty($this->get_safe($_POST['productname']))) { $func_array[] = 'invalid value, Product/Item'; } else { $this->get_safe($_POST['productname']) = stripslashes($this->get_safe(['productname'])); } if(empty($this->get_safe($_POST['description']))) { $func_array[] = 'invalid value, Description'; } else { $this->get_safe($_POST['description']) = stripslashes($this->get_safe($_POST['description'])); } if(sizeof($creat_array)>0) { foreach($func_array as $new_array); echo "$new_array"; } else { require '../new_function/new_item.php'; } } else { return false; } } } $controller = new item_controller(); $controller->check_first(); ?> Edited March 19, 2013 by jayson_ph Quote Link to comment https://forums.phpfreaks.com/topic/275865-using-mysql_real_escape_string-error/ Share on other sites More sharing options...
requinix Posted March 19, 2013 Share Posted March 19, 2013 $this->set_safe($_POST['categoryname']) = stripslashes($this->get_safe($_POST['categoryname']));You can't assign a value to the result of a function. Rethink what you're trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/275865-using-mysql_real_escape_string-error/#findComment-1419639 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.