Uncaught exception 'No_Result_Exception' with message 'No results' - php

I'm working with this codeigniter script called Crysandrea, anyways everything was going smoothly until I tried out the trading system.
Here is the error.
Fatal error: Uncaught exception 'No_Result_Exception' with message 'No results' in C:\xampp\htdocs\application\core\CRYS_Model.php:97
Stack trace: #0 C:\xampp\htdocs\application\core\CRYS_Model.php(190):
CRYS_Model->_process_result(Object(CI_DB_mysql_result), 1) #1
C:\xampp\htdocs\application\controllers\trades.php(535):
CRYS_Composite_Model->findRelation('3', '1', '*', Array) #2 [internal
function]: Trades->accept_trade('2') #3
C:\xampp\htdocs\system\core\CodeIgniter.php(359):
call_user_func_array(Array, Array) #4 C:\xampp\htdocs\index.php(203):
require_once('C:\xampp\htdocs...') #5 {main} thrown in
C:\xampp\htdocs\application\core\CRYS_Model.php on line 97
Here's the code for CRYS_Model.php
protected function _process_result(&$result, $limit=1) {
if (!$result->result_array())
throw new No_Result_Exception();
if ($limit === 1)
return $result->row(0, static::$INNER_MODEL);
else
return $result->result(static::$INNER_MODEL);
}
If you need anything, please say so!

Related

I want to fetch app data by package name in php

I am using google-play-scraper. but I am getting below error while using it.
Fatal error: Uncaught Error: Call to undefined method Symfony\Component\BrowserKit\Response::getStatus() in C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\raulr\google-play-scraper\src\Client.php:15 Stack trace: #0 C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\symfony\browser-kit\AbstractBrowser.php(401): Raulr\GooglePlayScraper\Client->filterResponse(Object(Symfony\Component\BrowserKit\Response)) #1 C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\raulr\google-play-scraper\src\Scraper.php(367): Symfony\Component\BrowserKit\AbstractBrowser->request('GET', 'https://play.go...') #2 C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\raulr\google-play-scraper\src\Scraper.php(108): Raulr\GooglePlayScraper\Scraper->request('/store/apps/det...', Array) #3 C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\examples\app.php(10): Raulr\GooglePlayScraper\Scraper->getApp('com.google.andr...') #4 {main} thrown in C:\xampp\htdocs\plystore\demo_123\google-play-scraper-master\vendor\raulr\google-play-scraper\src\Client.php on line 15
After getting this error I try the below solution.
Solution URL: https://github.com/raulr/google-play-scraper/issues/35
`[Change getStatus() to getStatusCode() ]
vendor\raulr\google-play-scraper\src\Client.php
Line: 15
$response->getStatus()
to
$response->getStatusCode()
vendor\raulr\google-play-scraper\src\Scraper.php
Line: 368
$status_code = $this->client->getResponse()->getStatus();
to
$status_code = $this->client->getResponse()->getStatusCode();`
but it did not work for me.

Requests Operation is not working on Raw PHP

I have been trying to implement calling the specific API from the API I created. It is raw PHP, no framework is being used. Just a normal php file. Since I know that I have implemented the code right and tested few things on MAMP server, but the problem is Every time I try to call the API, I get 500 Internal Server Error.
I have downloaded the Requests.php file from this script from git: git clone git://github.com/rmccue/Requests.git
The file path is defined correct since I have reverified it.
Possibility is Request file is not getting implemented. Have included the Request file in my php file.
Code:
<?php
include('Applications/MAMP/htdocs/api/Requests/library/Requests.php');
$response = array();
$request_method = $_SERVER['REQUEST_METHOD'];
if( $request_method == 'GET' ){
Requests::register_autoloader();
$response = Requests::get('https://nut-case.s3.amazonaws.com/jobs.json');
echo $response;
}else {
echo 'No defined function for this method. Please use GET only';
}
?>
PHP Error Logs
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
[07-Jan-2020 13:26:51 UTC] PHP Fatal error: Uncaught Requests_Exception: cURL error 28: Operation timed out after 10000 milliseconds with 1131134 out of 1459668 bytes received in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php:422
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
[07-Jan-2020 13:27:04 UTC] PHP Fatal error: Uncaught Requests_Exception: cURL error 28: Operation timed out after 10000 milliseconds with 1113726 out of 1459668 bytes received in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php:422
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
[07-Jan-2020 13:28:02 UTC] PHP Fatal error: Uncaught Requests_Exception: cURL error 28: Operation timed out after 10000 milliseconds with 1096318 out of 1459668 bytes received in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php:422
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
[07-Jan-2020 13:28:16 UTC] PHP Fatal error: Uncaught Requests_Exception: cURL error 28: Operation timed out after 10000 milliseconds with 1113726 out of 1459668 bytes received in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php:422
Stack trace:
#0 /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php(177): Requests_Transport_cURL->process_response('{"data":[{"_id"...', Array)
#1 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(379): Requests_Transport_cURL->request('https://nut-cas...', Array, NULL, Array)
#2 /Applications/MAMP/htdocs/api/Requests/library/Requests.php(231): Requests::request('https://nut-cas...', Array, NULL, 'GET', Array)
#3 /Applications/MAMP/htdocs/api/index.php(29): Requests::get('https://nut-cas...')
#4 {main}
thrown in /Applications/MAMP/htdocs/api/Requests/library/Requests/Transport/cURL.php on line 422
The url is fine. I am trying my API on my localhost using MAMP, and the API is running fine. This is for testing purposes, since I am learning PHP for the first time. Please help. Thanks
Maybe you can try this to get the data.
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['phone_num'])) {
if (trim($_POST['phone_num']) != '') {
$ch = curl_init('https://nut-case.s3.amazonaws.com/jobs.json');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // The number of seconds to wait while trying to connect. Use 0 to wait indefinitely.
curl_setopt($ch, CURLOPT_TIMEOUT, 30); // The maximum number of seconds to allow cURL functions to execute.
$data = curl_exec($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// Check if the request has status 200 ok
if ($httpStatus == 200) {
var_dump(json_decode($data));
} else {
//return an error
}
} else {
// return error invalid phone_num
}
}

Script dies when trying to use $model->save()

I am trying to use $model->save() .. but i can't get the error messages like the documentation instead the error message appears with trace error then the script dies.
for example i am trying to use this code:
$user = new Users();
$user->name = "Name";
if(!$user->save()){
//do stuff if there is an error
}
the problem is that i always get the validation error like this and the script dies and never returns false to enter the if condition :
password is required
#0 ..../UsersController.php(106): Phalcon\Mvc\Model->save()
#1 [internal function]: ....\UsersController->createAction()
#2 [internal function]: Phalcon\Dispatcher->callActionMethod(Object(....\UsersController), 'createAction', Array)
#3 [internal function]: Phalcon\Dispatcher->_dispatch()
#4 [internal function]: Phalcon\Dispatcher->dispatch()
#5 ....\public\index.php(41): Phalcon\Mvc\Application->handle()
#6 {main}**
I Finally found the solution, I found that somewhere in the services.php
this line was enabled and that what caused the exception to be thrown
Phalcon\Mvc\Model::setup(['exceptionOnFailedSave' => true] and after turning it to false,i can easily add my conditions and check the errors message using this code.
if ($model->save() === false) {
$messages = $model->getMessages();
foreach ($messages as $message) {
echo $message, "\n";
}
}
you can send flash error using
$this->flash->error("too bad! the form had errors");
$this->flash->success("yes!, everything went very smoothly");
$this->flash->notice("this a very important information");
$this->flash->warning("best check yo self, you're not looking too good.");
see documentation
https://docs.phalconphp.com/en/latest/reference/flash.html

SOAP API Uncaught SoapFault exception

I'm trying to upload a torrent into torcache.net, using their SOAP API.
<?php
$client = new SoapClient('http://torcache.net/torcache.wsdl');
$info_hash = $client->cacheTorrent(base64_encode(file_get_contents('test.torrent')));
print_r($info_hash);
?>
Here's what I receive:
Fatal error: Uncaught SoapFault exception: [HTTP] Not Found in D:\Web\data\localweb\test.php:4
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://torcache...', 'urn:xmethods-de...', 1, 0)
#1 D:\Web\data\localweb\test.php(4): SoapClient->__call('cacheTorrent', Array)
#2 D:\Web\data\localweb\test.php(4): SoapClient->cacheTorrent('ZDg6YW5ub3VuY2U...')
#3 {main}
thrown in D:\Web\data\localweb\test.php on line 4
Refer this, see if you can get any help.
or
Try this:
<?php
try {
$x = #new SoapClient("http://torcache.net/torcache.wsdl");
} catch (Exception $e) {
echo $e->getMessage();
}
?>

Fatal error: Uncaught exception 'Exception' with message 'Serialization of

Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php:138 Stack trace:
#0 C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php(138): session_write_close()
#1 [internal function]: CHttpSession->close()
#2 {main} Next exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php:138 Stack trace:
#0 C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php(0): session_write_close()
#1 [internal function]: CHttpSession->close()
#2 {main} Next exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php:138 Stack trace:
#0 C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php(0): session_write_close()
#1 [internal function]: CHttpSession->close()
#2 {ma in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php on line 138
how to fix this issue i'm unable to find any answer
I had the same error. I corrected it using an array of session
foreach ($output['tab_displayId'] as $id_display => $id_param){
$test = new ClParaWidget($id_param, $id_display);
$output[$id_display] = $test->toString($id_display);
if (Yii::app()->session['S' . $id_display] != $output[$id_display])
Yii::app()->session['S' . $id_display] = $output[$id_display];
}
I give more explanation. If I want to save in a session value an array:
Yii::app()->session['data'] = $array_data;
sometimes, this code returns an error:
Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in C:\xampp\htdocs\t9l_loyaltyprogram\common\lib\Yii\web\CHttpSession.php:138 Stack trace:
for that, I propose to use a array of session like here:
foreach ($array_data as $id => $data)
Yii::app()->session['S_' . $id] = $data;

Categories