Php symfony Fatal Error - 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.

Related

Function Error (Fatal error: Function name must be a string)

<?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.

Uncaught Error: Call to undefined method DB::execute()

I am using indieteq-php-my-sql-pdo-database-class I found on GitHub
I have created a little page to try and display some database information as seen below, however I receive the error below my test page script below;
My Test Page
<?php
require("Db.class.php");
$db = new Db();
$db->query("SELECT * FROM faction_territories");
if ($db->execute()) {
while ($row = $db->fetch(PDO::FETCH_ASSOC)) {
echo '<tr>
<td>'.$row['territory_id'].'</td>
<td>'.$row['name'].'</td>
<td>'.$row['density'].'</td>
<td>'.$row['sector'].'</td>
<td>'.$row['size'].'</td>
<td>'.$row['respect'].'</td>
<td>'.$row['faction_name'].'</td>
</tr>';
}
echo '</table>';
}
?>
Error
Fatal error: Uncaught Error: Call to undefined method DB::execute() in
/var/www/.../index.php:7 Stack trace: #0 {main} thrown in
/var/www/.../index.php on line 7
Questions
As you'll be able to tell, I'm somewhat new to PHP & PDO. Some nice pointers to where I am going wrong would be nice with any example code please.
The $db->query already execute the query. You just need to iterate over the result.
See here: https://github.com/wickyaswal/indieteq-php-my-sql-pdo-database-class/blob/master/Db.class.php#L189

getQty() giving fatal error in magento 1.9

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();

[PHP]Severity: Compile Error Message: Cannot redeclare <function> - CodeIgniter

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.

running using xampp error on ubuntu : Fatal error: Call to a member function rowCount() on a non-object

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

Categories