Why am I getting error class ImagePixel not found? - php

Here is a snippit of my code:
//$page defined above
$opening_border = new ImagickDraw();
$opening_border->setFillColor('none');
$opening_border->setstrokecolor(new ImagePixel('#000000'));
$opening_border->setstrokewidth(10);
$opening_border->setstrokeantialias(FALSE);
$opening_border->rectangle($left_px, $top_px, $width_px, $height_px);
$opening_img->drawimage($opening_border);
$page->compositeImage($opening_img, Imagick::COMPOSITE_DEFAULT, $left_px, $top_px);
This is the error I am getting:
Fatal error: Class 'ImagePixel' not found in /data/www-test/content/sites/all/modules/tf_modules/tf_fulfill/tf_fulfill_pdf_generate.php on line 333
This is part of my PHP info

ImagickPixel is the correct name

Related

PHP Fatal error: Uncaught MongoDB\Driver\Exception\InvalidArgumentException: Error parsing ObjectId string

I'm trying to Query Data from my Database to put the result into the value form an input.
but when I want to fetch the Data, following error is showing up:
Fatal error: Uncaught MongoDB\Driver\Exception\InvalidArgumentException: Error parsing ObjectId string: 5f4286324becb3f60cbb866e
I really don't know how to solve it, i searched like 2 hours in the WWW.. I hope someone can help me..
Here's my Code:
$id = $_POST['id'];
echo $id;
$client = new MongoDB\Client;
$db = $client->thesis;
$personen = $db->Personen;
$document = $personen->findOne(['_id' => new MongoDB\BSON\ObjectId($id)]);
I'm getting the ID with the echo but the findOne Method isn't working.
Thanks for your answers :)
Cheeres

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

Fatal error: Call to undefined method with Wordnik API

Not sure if this is an Wordnik API issue or just a php error on my part. Here is my current code:
require('./wordnik/Swagger.php');
require('./wordnik/WordsApi.php');
$myAPIKey = '00144cdc1140c4192780f08c3f608399234240dcb560d3e4b';
$client = new APIClient($myAPIKey, 'http://api.wordnik.com/v4');
$wordApi = new WordApi($client);
$input = new WordObject();
$input->includePartOfSpeech='noun';
$input->excludePartOfSpeech='affix,article,connjunction,preposition,abbreviation,suffix';
$input->hasDictionaryDef='true';
$input->minCorpusCount='10000';
$input->maxCorpusCount='null';
$input->minDictionaryCount='20';
$input->maxDictionaryCount=null;
$input->minLength='4';
$input->maxLength='20';
$random_word = $wordApi->getRandomWord($input); //THIS IS THE ERROR LINE
print $random_word->text;
and here is the error I get:
Fatal error: Call to undefined method WordApi::getRandomWord()
Any help is greatly appreciated. The error is happening on that line towards the bottom, just not sure why. Thank you.
getRandomWord() is defined in WordsApi (plural words).
You have: WordApi
You need: WordsApi

Get the nodeValue for a tag

I am trying to get the nodeValue of any tag found in an html page but am getting an error and i can't figure what is causing that error. Fatal error: Fatal error: Call to undefined method DOMDocument::getElementByTagName() in C:\xampplite\htdocs\msite\getscriptnodeValue.php on line 5..here is my code..Can anyone please help me??Thnxx in advance.
$file=file_get_contents('test.txt');
$doc=new DOMDocument();
#$doc->loadHTML('<?xml encoding="UTF-8">'.$file);
$data=$doc->getElementByTagName('div');
for($i=0;$i<$data->length;$i++){
$getTag=$data->item($i);
echo $getTag->nodeValue;
echo"<br/>";
}
The method name is getElementsByTagName() (with an S) not getElementByTagName().
Change to:
$data=$doc->getElementsByTagName('div');
// ^ missing s

Categories