Fatal error: Cannot re-assign auto-global variable _POST when I am installing wordpress theme - wordpress-theming

Fatal error: Cannot re-assign auto-global variable _POST when I am installing wordpress theme
PHP Version 5.4.41
Getting following error : -
Fatal error: Cannot re-assign auto-global variable _POST in /public_html/linuxnlinux.com/wp-content/themes/Answers_v1.2/Answers/library/functions/custom_functions.php on line 1360
Code at line 1360 is : -
}
function get_user_name($uid)
{
global $wpdb;
return $wpdb->get_var("select display_name from $wpdb->users where ID=\"$uid\"");
}
function veryfy_login_and_proced($_POST,$redirecturl = '') // 1360 line
{
$secure_cookie = '';
if ( !empty($_POST['log']) && !force_ssl_admin() ) {
$user_name = sanitize_user($_POST['log']);
if ( $user = get_userdatabylogin($user_name) ) {
if ( get_user_option('use_ssl', $user->ID) ) {
$secure_cookie = true;
force_ssl_admin(true);
}
}
}

Superglobals are not allowed to be used as parameters to a function since PHP 5.4
http://php.net/manual/en/language.variables.superglobals.php#112184
So your function needs to look like this:
function veryfy_login_and_proced() // 1360 line
You can then pass your parameters inside the function.
Hope that helps.

Related

Mysql error - Commands out of sync; you can't run this command now - postman error - codeigniter

My application is in codeigniter framework , in my application I written a rest api function. When I call that function from postman i got an error:
ERROR: Commands out of sync; you can't run this command now
Firstly I call a model function for invoking a stored procedure and then i calls a normal query .The provided codes are representational purpose only.
My API function is :(All are dummy functions)
public function products_get()
{
$cat_id = $this->input->get('cat_id');
$sub_categories = $this->Products_model->fetch_cate($cat_id); //dummy functions
$products = $this->Products_model->get_pdts($cat_id);
$data['status'] = TRUE;
$data['message'] = 'success';
$data['categories'] = $products;
$this->set_response($data, self::HTTP_OK);
}
My model function is:
public function fetch_cate($cat_id)
{
$query = $this->db->query("CALL getSubcategory($cat_id)");
return $query->result();
}
public function get_pdts()
{
return $this->db->get('category_product')->result();
}
I find a decent solution from internet just posting after this question :
Add this line of code ->
mysqli_next_result( $this->db->conn_id );
After the stored procedure call ->
$query = $this->db->query("CALL getSubcategory($cat_id)");
mysqli_next_result( $this->db->conn_id ); //add this line of code

PHP Fatal error Uncaught Error: Call to a member function getMetaTitle() on null in

I'm getting the following error but it says it in Magento core. I was wondering how to debug this because I'm sure there is nothing wrong in Magentos core.
Here is the error:
30-Apr-2018 18:05:23 UTC] PHP Fatal error: Uncaught Error: Call to a member function getMetaTitle() on null in /home/example/public_html/app/code/core/Mage/Catalog/Block/Product/View.php:18
Stack trace:
#0 /home/example/public_html/app/code/core/Mage/Core/Block/Abstract.php(139): Mage_Catalog_Block_Product_View->_prepareLayout()
#1 /home/example/public_html/app/code/core/Mage/Core/Model/Layout.php(322): Mage_Core_Block_Abstract->setLayout(Object(Inchoo_PHP7_Model_Layout))
#2 /home/example/public_html/app/code/core/Mage/Core/Model/Layout.php(332): Mage_Core_Model_Layout->createBlock('review/product_...', 'product.info')
#3 /home/example/public_html/app/code/core/Mage/Core/Model/Layout.php(147): Mage_Core_Model_Layout->addBlock('review/product_...', 'product.info')
#4 /home/example/public_html/app/code/core/Mage/Core/Model/Layout.php(119): Mage_Core_Model_Layout->_generateBlock(Object(Mage_Core_Model_Layout_Element), Object(Mage_Core_Model_Layout_Element))
#5 /home/example/public_html/app/co in /home/example/public_html/app/code/core/Mage/Catalog/Block/Product/View.php on line 18
Here is /home/angelsforeveryon/public_html/app/code/core/Mage/Catalog/Block/Product/View.php:18
protected function _prepareLayout()
{
$this->getLayout()->createBlock('catalog/breadcrumbs');
$headBlock = $this->getLayout()->getBlock('head');
if ($headBlock) {
$product = $this->getProduct();
line 18 here --> $title = $product->getMetaTitle();
if ($title) {
$headBlock->setTitle($title);
}
$keyword = $product->getMetaKeyword();
$currentCategory = Mage::registry('current_category');
if ($keyword) {
$headBlock->setKeywords($keyword);
} elseif ($currentCategory) {
$headBlock->setKeywords($product->getName());
}
$description = $product->getMetaDescription();
if ($description) {
$headBlock->setDescription( ($description) );
} else {
$headBlock->setDescription(Mage::helper('core/string')->substr($product->getDescription(), 0, 255));
}
if ($this->helper('catalog/product')->canUseCanonicalTag()) {
$params = array('_ignore_category' => true);
$headBlock->addLinkRel('canonical', $product->getUrlModel()->getUrl($product, $params));
}
}
return parent::_prepareLayout();
}
Thanks
it looks like your product is null, you need make sure this function work well
$product = $this->getProduct();

Calling a function inside a function - converting AS2 to AS3

I currently have some code from here (https://github.com/jmhnilbog/Nilbog-Lib-AS2/blob/master/mx/mx/remoting/NetServiceProxy.as) which converts a function into a function. This code is shown below:
private var _allowRes:Boolean= false;
function __resolve( methodName:String ):Function {
if( _allowRes ) {
var f = function() :Object {
// did the user give a default client when he created this NetServiceProxy?
if (this.client != null) {
// Yes. Let's create a responder object.
arguments.unshift(new NetServiceProxyResponder(this, methodName));
}
else {
if (typeof(arguments[0].onResult) != "function") {
mx.remoting.NetServices.trace("NetServices", "warning", 3, "There is no defaultResponder, and no responder was given in call to " + methodName);
arguments.unshift(new NetServiceProxyResponder(this, methodName));
}
}
if(typeof(this.serviceName) == "function")
this.serviceName = this.servicename;
arguments.unshift(this.serviceName + "." + methodName);
return( this.nc.call.apply(this.nc, arguments));
};
return f;
}
else {
return null;
}
}
Basically what the code is designed to do is return a new function (returned as f) which performs the correct server operates. However, if I try and use this syntax in AS3, I get the following two errors:
Error: Syntax error: expecting semicolon before colon.
Error: Syntax error: else is unexpected.
How would I go about doing this? I know this is someone else's code, but I am trying to get the old AS1/2 mx.remoting functionality working in AS3. Cheers.

Codeigniter Displaying Information In A View?

I'm extracting two different sets of data from a function in my model (syntax below). I'm trying to display the data my view. I put the variable in var_dump and var_dump is displaying the requested information but I'm having a hard time accessing that information. I'm getting two different sets of error messages as well. They are below. How would I display the information in my view? Thanks everyone.
Site Controller
public function getAllInformation($year,$make,$model)
{
if(is_null($year)) return false;
if(is_null($make)) return false;
if(is_null($model)) return false;
$this->load->model('model_data');
$data['allvehicledata'] = $this->model_data->getJoinInformation($year,$make,$model);
$this->load->view('view_show_all_averages',$data);
}
Model_data
function getJoinInformation($year,$make,$model)
{
$data['getPrice'] = $this->getPrice($year,$make,$model);
$data['getOtherPrice'] = $this->getOtherPrice($year,$make,$model);
return $data;
}
function getPrice($year,$make,$model)
{
$this->db->select('*');
$this->db->from('tbl_car_description d');
$this->db->join('tbl_car_prices p', 'd.id = p.cardescription_id');
$this->db->where('d.year', $year);
$this->db->where('d.make', $make);
$this->db->where('d.model', $model);
$query = $this->db->get();
return $query->result();
}
function getOtherPrice($year,$make,$model)
{
$this->db->select('*');
$this->db->from('tbl_car_description d');
$this->db->where('d.year', $year);
$this->db->where('d.make', $make);
$this->db->where('d.model', $model);
$query = $this->db->get();
return $query->result();
}
View
<?php
var_dump($allvehicledata).'<br>';
//print_r($allvehicledata);
if(isset($allvehicledata) && !is_null($allvehicledata))
{
echo "Cities of " . $allvehicledata->cardescription_id . "<br />";
$id = $allvehicledata['getPrice']->id;
$model = $allvehicledata[0]->model;
$make = $allvehicledata->make;
echo "$id".'<br>';
echo "$make".'<br>';
echo "$model".'<br>';
echo $allvehicledata->year;
}
?>
Error Messages
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: views/view_show_all_averages.php
Line Number: 7
A PHP Error was encountered
Severity: Notice
Message: Undefined offset: 0
Filename: views/view_show_all_averages.php
Line Number: 9
In your controller you are assigning the result of function getJoinInformation to the variable allvehicledata. This variable is then assigned to the view.
The function getJoinInformation is returning an array with the following
$data = array(
'getPrice' => $this->getPrice($year,$make,$model),
'getOtherPrice' => $this->getOtherPrice($year,$make,$model)
);
So in your view you can access the attributes getPrice and getOtherPrice in the object $allvehicledata like
$allvehicledata->getPrice;
$allvehicledata->getOtherPrice;
In line 7 you try to access the attribute cardescription_id, which is not an attribute of the object $allvehicledata.
I think this is an attribute which is get from the db query, so you should try to access it allvehicledata->getPrice->cardescription_id or allvehicledata->getOtherPrice->cardescription_id.
In line 9 you try to access some data stored in an array $model = $allvehicledata[0]->model;, but $allvehicledata is not an array.

dlopen load library correct,but run the program,the result is incorrect

I use dlopen, dlsym load library function. When I run the program, I met this problem:
use dlopen load function, call the function correct but the result is incorrect
don't use dlopen and call the function directly,the result is correct
How can I find the problem?
Example:
void *dl_handle = NULL;
char *error = NULL;
/* Open the shared object */
dl_handle = dlopen(pLibraryName, RTLD_LAZY );
if (!dl_handle)
{
return -1
}
char* error = NULL;
pFunc = dlsym( dlHandle, "mysql_rollback");
error = dlerror();
if (error != NULL)\
{
return -1
}