<?php
require_once('includes/auth.php');
function getMarkets(){
$count_markets=querydb("SELECT count(*) as marketcount from markets ");
$result=$count_markets('marketcount');
return $result;
}
I have the above code and i am getting the error below:
Fatal error: Function name must be a string
Seen the Error was using $count_markets('marketcount'); instead of $count_markets['marketcount'];
$result=$count_markets('marketcount'); - remove $ from count_markets.
Related
I am trying to get the collection based on product and quote Id using,
$quotecollection = Mage::getModel('sales/quote_item')->getCollection()->addFieldToFilter('quote_id',$quoteId)->addFieldToFilter('product_id',$product_id);
$quotecollectionaArr = $quotecollection->getData();
echo $quotecollection->getQty();
which gives the following error
Fatal error: Call to undefined method
Mage_Sales_Model_Resource_Quote_Item_Collection::getQty() in
C:\xampp\htdocs....
Please help.
You should use getFirstItem()
$quotecollection = Mage::getModel('sales/quote_item')->getCollection()->addFieldToFilter('quote_id',$quoteId)->addFieldToFilter('product_id',$product_id)->getFirstItem();
echo $quotecollection->getQty();
I have this function:
function vai_a_capo($cont_sett){ ---> line 3
if($cont_sett >= 7){
echo "</tr><tr>";
return TRUE;
}else{
return FALSE;
}
} ---> line 10
I'm using CodeIgniter version: 3.1.2.
When I go to the link: ../index.php/home/pages/disponibilita it say to me:
Fatal error: Cannot redeclare vai_a_capo() (previously declared in C:\xampp\htdocs\CI___________\application\views\pages\disponibilita.php:3) in C:\xampp\htdocs\CI___________\application\views\pages\disponibilita.php on line 10
Thanks for the answers. Bye.
EDIT:
It has been solved. In my controller (Home) I declared by mistake twice of these:
$this->load->view('pages/disponibilita', $data);
As Paul points out.. yes you could change the function name but since your site is likely riddled with calls to this function, that would likely be a lot of work. Instead, just check to see if the function is already defined by adding 2 lines, like this...
if (!function_exists('vai_a_capo')) { // new line to go above function
function vai_a_capo($cont_sett){ ---> line 3
if($cont_sett >= 7){
echo "</tr><tr>";
return TRUE;
}else{
return FALSE;
}
}
} // new line below function
I should point out, this edit needs to go where your code is trying to define the function a 2nd time.. In \application\views\pages\disponibilita.php on line 10
You should take care of your error messages:
Fatal error: Cannot redeclare vai_a_capo() (previously declared in
C:\xampp\htdocs\CI___________\application\views\pages\disponibilita.php:3) in > > C:\xampp\htdocs\CI___________\application\views\pages\disponibilita.php on line 10
They tell you, that the method you are trying to declare has already been declared in disponibilita.php. You have to give your method another name.
I'm testing a program running well using xampp and Windows 7,
But when i'm upload to the server using Ubuntu (mysql, php, apache using apt-get) it's getting error
Fatal error: Call to a member function rowCount() on a non-object in /var/www/siarsip/class/user.php on line 56
Here the code snipped :
function getAllUser(){
$query=$this->db1->query("SELECT a.user_id,a.username,a.password,a.NIP,a.role,b.category,a.input_date,a.last_update FROM users as a RIGHT JOIN user_categories as b ON a.role=b.usercat_id ORDER BY role");
$jml_data=$query->rowCount();
if($jml_data>=1){
$hasil=$query->fetchAll(); //line 56
return $hasil;
}else{
return $jml_data;
}
}
I've tried to change line 56 to :
if(!empty($query) AND $jml_data > 0) {
Still not working.
update :
Using #cjriii code, i've update line 56 to using this :
if(is_object($query))
{
{
code here
}
}
Now there's no error, i've tried to login produces same error
"Fatal error: Call to a member function rowCount() on a non-object in /var/www/siarsip/class/user.php on line 74"
function loginUser($username,$password){
$password_md5=md5($password);
$query=$this->db1->query("SELECT*FROM users WHERE username='$username' AND password='$password_md5'");
if(is_object($query))
{
$hasil=$query->rowCount(); //line 74
return $hasil;
}
}
I've insert the code again to line 74
if(is_object($query))
{
Produces no error.
But now i cannot login using the username and password that usually works.
Need another advice bro..
Two things:
Test if $query is an object before calling a method on it. Thats' where the error comes from.
Second, instead of testing for !empty($query), try testing for is_object($query).
if(is_object($query))
{
$jml_data = $query->rowCount();
if($jml_data >= 1)
{
//rest of your code here
}
else
return $jml_data;
}
Edit:
Please check the documention on empty(): Your call may be returning a valid value for empty to return false.
http://php.net/empty
http://php.net/manual/en/function.is-object.php
getNbResults()) : ?> getResults() as $offer) : ?> getMOVIE()->getTitle(); ?>
while running this success page i am getting the following error: Fatal error: Call to a member
function getTitle() on a non-object in
C:\xampp\htdocs\Menakaa\TicketBounty\dev\apps\backend\modules\offer\templates\searchOfferSuccess.php on line 68
Try to close foreach loop. at this time this loop is accepting only first line.
I believe my class is correct but when I try to echo the output of the class I get an error on line 28: the line " echo 'Your full name ...." is line 28. Any help would be nice
<?php
echo 'Your full name is ' . $person->retrieve_full_name() . '.';
?>
This is where I created the function "retrieve_full_name"
public function __retrieve_full_name() {
$fullname = $this->firstname . ' . ' . $this->lastname;
return $fullname;
}/* This ends the Full Name Function*/
the error I get is
Fatal error: Call to undefined method stdClass::retrieve_full_name() in /home/mjcrawle/processlogin2.php on line 28
your function is called __retrieve_full_name, but you call retrieve_full_name. notice the missing underscores.
double underscores are usually the prefix for php internal/magic functions, i would advise against using them in your function names.
Your immediate error is due to the fact that you call your method by the wrong name. And:
don't use underscores to start a method name
don't use underscores in method names at all, if you care for best practice, use camel casing instead retrieveFullName().
public function retrieve_full_name() {