Message: Undefined index: rows Filename: tcpdf/tcpdf.php Line Number: 16935 - php

if (($dom[$key]['value'] == 'tr')) {
$dom[$key]['cols'] = 0;
if ($thead) {
$dom[$key]['thead'] = true;
} else {
$dom[$key]['thead'] = false;
++$dom[($dom[$key]['parent'])]['rows'];
array_push($dom[($dom[$key]['parent'])]['trids'], $key);
}
}
these part shows error.
Message: array_push() expects parameter 1 to be array, null given
Filename: tcpdf/tcpdf.php
Line Number: 16937

Related

Notice: Undefined offset: 0 in C:\xampp\htdocs\isan\hasildata.php on line 21

Hi I receive the following error in my homework and I do not know what is the problem hasildata.php on line 21 :
$dataJson = file_get_contents("https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=".$from."&destinations=".$to."&key=%20AIzaSyCWpwVwu1hO6TJW1H8x_zlhrLfbSbQ2r3o");
$data = json_decode($dataJson,true);
$nilaiJarak = $data['rows'][0]['elements'][0]['distance']['text'];
$time=$data['rows'][0]['elements'][0]['duration']['text'];
Screenshot
You must check whether your request is OK or not
$dataJson = file_get_contents("https://maps.googleapis.com/maps/api/distancematrix/json?units=metric&origins=".$from."&destinations=".$to."&key=%20AIzaSyCWpwVwu1hO6TJW1H8x_zlhrLfbSbQ2r3o");
$data = json_decode($dataJson,true);
if ($data['status'] !== "OK") {
// Error
echo $data['error_message'];
// Do something
} else {
$nilaiJarak = $data['rows'][0]['elements'][0]['distance']['text'];
$time=$data['rows'][0]['elements'][0]['duration']['text'];
}

Magento says Warning: Invalid argument supplied for foreach() on line 4 in my code

Magento says Warning: Invalid argument supplied for foreach() on line 4 in my code. Not sure why. Any ideas?
public function itemIsVirtualGift($item){
$product = $item->getProduct();
$_customOptions = $product->getTypeInstance(true)->getOrderOptions($product);
foreach($_customOptions['options'] as $_option){
if (strpos($_option['label'], 'Is this a gift') !== false && strpos($_option['value'], 'Yes') !== false){
return true;
}
}
return false;
}

PHP Catchable fatal error: Argument 1 passed to must be of the type array, null given, called in on line 208 and defined

I have been facing a weird issue that I cant get fixed. Long story short, when I join a minigame on a game that I am creating, it goes fine! But when I exit out of the minigame, it should send me back into the room, but instead it gives me an error.
This is the error:
PHP Catchable fatal error: Argument 1 passed to
Sweater\Server::leaveTable() must be of the type array, string given,
called in /usr/share/nginx/Sweater/Sweater/GameHandler.php on line 208
and defined in /usr/share/nginx/Sweater/Sweater/GameHandler.php on
line 184
I did some research before asking this question and tried the solutions that I came across, but they sadly did not work.
GameHandler.php handleLeaveTable:
function handleLeaveTable(Array $arrData, Client $objClient) {
$intPlayer = $arrData[0];
$this->leaveTable($intPlayer); // Line 208
}
GameHandler.php leaveTable:
function leaveTable(Array $arrData, Client $objClient) { // Line 184
$intPlayer = $arrData[4];
$tableId = $intPlayer->tableId;
if($tableId !== null) {
$seatId = array_search($intPlayer, $this->playersByTableId[$tableId]);
$opponentSeatId = $seatId == 0 ? 1 : 0;
if(isset($this->playersByTableId[$tableId][$opponentSeatId])) {
$this->playersByTableId[$tableId][$opponentSeatId]->addCoins(10);
}
unset($this->playersByTableId[$tableId][$seatId]);
unset($this->tablePopulationById[$tableId][$intPlayer->$strUsername]);
$objClient->sendXt('ut', $objClient->getIntRoom(), $tableId, $seatId);
$intPlayer->tableId = null;
if(count($this->playersByTableId[$tableId]) == 0) {
$this->playersByTableId[$tableId] = array();
$this->gamesByTableId[$tableId] = null;
}
}
}
What is the issue here? I have checked everything and could not come to a solution.
Edit, What $arrData is:
function decodeData($strData){
$arrData = simplexml_load_string($strData, 'SimpleXMLElement', LIBXML_NOCDATA);
if($arrData === false){
throw new Exceptions\HandlingException('Unable to parse client\'s XML data');
}
$arrData = json_decode(json_encode((array)$arrData), true);
return $arrData;
}
function handleData($strData, $objClient){
$arrData = explode($this->arrConfig['Packets']['Delimiter'], $strData);
array_pop($arrData);
foreach($arrData as $strData){
Silk\Logger::Log('Received data: ' . $strData);
$strSubstring = substr($strData, 0, 1);
$blnPossibleXML = $strSubstring == '<' ? true : false;
$blnPossibleGame = $strSubstring == '%' ? true : false;
if($blnPossibleXML === false && $blnPossibleGame === false){
throw new Exceptions\HandlingException('Bad client detected!');
}
$blnPossibleXML ?
$this->handleXMLData($strData, $objClient):
$this->handleGameData($strData, $objClient);
}
unset($arrData);
}
PHP Catchable fatal error: Argument 1 passed to
Sweater\Server::leaveTable() must be of the type array, string given,
called in /usr/share/nginx/Sweater/Sweater/GameHandler.php on line 208
and defined in /usr/share/nginx/Sweater/Sweater/GameHandler.php on
line 184
From $arrData you take the first element which is string
$intPlayer = $arrData[0];
$this->leaveTable($intPlayer); // Line 208
In GameHandler.php handleLeaveTable:
You take the first element form an array
And then in GameHandler.php leaveTable:
You are trying to access that element as an array and then take the 5th element

PHP Error was encountered Codeigniter

someone from freelancer created this web based software for us. By mistake i deleted all the medical examination (i'm a doctor assistant) from the control panel.
The software now gives me this error:
Message: Undefined variable: data
Filename: models/gestione_model.php
Line Number: 127
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: models/gestione_model.php
Line Number: 127
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: data
Filename: models/gestione_model.php
Line Number: 127
A PHP Error was encountered
Severity: Warning
Message: Invalid argument supplied for foreach()
Filename: models/gestione_model.php
Line Number: 127
I find the line 27 here:
public function conta_visite($s)
{
$query = $this->db->get('oggetti');
if ($query->num_rows() > 0) {
$data = $query->result_array();
}
$aperte = 0;
$chiuse = 0;
foreach ($data as $d) {
if (new DateTime() > new DateTime($d['DataVisita'])) $chiuse++;
else $aperte++;
}
if($s == 1) return $aperte;
else return $chiuse;
}
Can someone help me please? Thanks
you are closing IF before foreach!
public function conta_visite($s) {
$query = $this->db->get('oggetti');
if ($query->num_rows() > 0) {
$data = $query->result_array();
} // HERE if result is ==0 then $data does not exist
$aperte = 0; $chiuse = 0; foreach ($data as $d) {
if (new DateTime() > new DateTime($d['DataVisita'])) $chiuse++;
else $aperte++;
}
if($s == 1) return $aperte;
else return $chiuse;
You need to make sure that $data is set before using it. If no rows are returned then $data is not set and you get errors when trying to process it.
if ($query->num_rows() > 0) {
$data = $query->result_array();
} else {
//do what needs to be done if the database does not return any rows
$data = array(); //empty array maybe?
}

Notice: Undefined offset: 0 using Array in PHP

When I'm executing this code-
public $speaker_list=array();
for($i=0;$i<$nbre_speaker;$i++)
{
$speaker_list[$i]=new Speaker($_POST['speaker'+$i],$_POST['pro_speaker'+$i],$_POST['bio_speaker'+$i]);
}
I'm getting the error:
Notice: Undefined offset: 0
Notice: Undefined offset: 1
Assuming $nbre_speaker is set to something sensible outside the code you provided.
Try this
public $speaker_list = array();
for($i=0; $i < $nbre_speaker; $i++)
{
if ( isset($_POST['speaker'.$i], $_POST['pro_speaker'.$i], $_POST['bio_speaker'.$i] )) {
$speaker_list[$i] = new Speaker($_POST['speaker'.$i],
$_POST['pro_speaker'.$i],
$_POST['bio_speaker'.$i]);
} else {
// report error, or do something to fix it.
}
}

Categories