PHP Mongo Library overflow detected - php

i've a problem with the MongoDB PHP library. I'am trying to find something in a collection but get this error.
Fatal error:
Uncaught MongoDB\Driver\Exception\InvalidArgumentException: Integer overflow detected on your platform: 1484960424767 in C:\xampp\htdocs\gameid\vendor\mongodb\mongodb\src\Operation\Find.php:222
Stack trace:
#0 C:\xampp\htdocs\gameid\vendor\mongodb\mongodb\src\Operation\Find.php(222): MongoDB\Driver\Cursor->setTypeMap(Array)
#1 C:\xampp\htdocs\gameid\vendor\mongodb\mongodb\src\Operation\FindOne.php(105): MongoDB\Operation\Find->execute(Object(MongoDB\Driver\Server))
#2 C:\xampp\htdocs\gameid\vendor\mongodb\mongodb\src\Collection.php(559): MongoDB\Operation\FindOne->execute(Object(MongoDB\Driver\Server))
#3 C:\xampp\htdocs\gameid\index.php(7): MongoDB\Collection->findOne(Array)
#4 {main} Next MongoDB\Driver\Exception\InvalidArgumentException: Integer overflow detected on your platform: 1484960529934 in C:\xampp\htdocs\gameid\vendor\mongodb\mongodb\src\Operation\Find.php:222
Stack trace:
#0 C:\xampp\htdocs\gameid\vendor\mongodb\mongodb\src\Operation\Find.php(222): MongoDB\Driver\Cursor->setTypeMap(Array)
#1 C:\ in C:\xampp\htdocs\gameid\vendor\mongodb\mongodb\src\Operation\Find.php on line 222
Here is my source code:
$con = new MongoDB\Client('mongodb://user:pwd#ip:port/ripes');
$con = $con->ripes->games;
$result = $con->findOne(['gameID' => 'KUDl-xvjWkPJkjTRf-']);
What is wrong? If no entry exists with the id, PHP does not report any errors.

I just encountered the same Integer overflow PHP exception. Take a look at your error message again, it is telling you exactly what caused the exception:
Integer overflow detected on your platform: 1484960424767
I was able to use Robo3T (RoboMongo) to view the document in question and see the field with the value that caused the exception (1484960424767 in your case). In the MongoDB document, the field was defined as type NumberLong(), and the value exceeds PHP's capability to parse long integers on the version you're using... most likely 32-bit PHP. Try using 64-bit PHP, if possible.
In my case, the document field was supposed to be a string, so I had to modify the document-creation script to force the value to be a string type.
$doc = array(
"field" => (string)$long_number_value
);

Related

How to get PHP 8 to properly DO OR DIE with MYSQL queries? [duplicate]

This question already has answers here:
mysqli or die, does it have to die?
(4 answers)
What to do with mysqli problems? Errors like mysqli_fetch_array(): Argument #1 must be of type mysqli_result and such
(1 answer)
Closed 22 days ago.
I switched to PHP 8.2 a couple weeks ago (from PHP 7.0.something), but I have issues with it thinking every minor error from mysqli is fatal and fails to run the "die" part. This is an except from my MySQL interface class (this is for development use) that I've tried to get to work properly with PHP 8:
public function query($query) {
$result = mysqli_query($this->db_link,$query) or $this->error('Unable to execute query<br/>'.$query);
return $result;
}
public function error($message) {
echo '<div align="center"><span style="font-size:150%;color:#FF0000;>ERROR! </span><span>'.$message.'<br /><br />'.mysqli_errno($this->db_link).': '.mysqli_error($this->db_link).'</span></div>';
}
If I happen to have a typo or other issue in the query, on PHP 7 and pretty much every older version for the past several years, this would correctly jump to the error part whenever there was the slightest issue with the query and tell me what I need to know to fix it.
PHP 8 on the other hand completely ignores the 'OR' part and instead throws "Fatal error: Uncaught mysqli_sql_exception" with a mess of an error message that does not help me much at all since it only has like 4 characters from the query, which really is not enough with dynamically built queries.
In this case I appear to have a typo somewhere in a rather chunky query (since it's dynamically built), but because PHP fails to run the 'OR' part I'm left with this error
Fatal error: Uncaught mysqli_sql_exception: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`0','0','1'' at line 9 in D:\web\testbase\include\mysql.php:53 Stack trace: #0 D:\web\testbase\include\mysql.php(53): mysqli_query(Object(mysqli), 'INSERT\r\n ...') #1 D:\web\testbase\work.php(36): db->query('INSERT\r\n ...') #2 {main} thrown in D:\web\testbase\include\mysql.php on line 53
Does PHP 8 require a completely different format for the 'DO OR DIE' approach or why does it refuse to execute the second half of the statement? (Note: I'm trying to avoid using actual 'DIE' as much as possible)
Also why does PHP go "fatal" here when a MySQL error by no means is fatal to the PHP parser. Sure the query fails, but I write my code to deal with that (or so I thought).

pisdk php when get values use ArcValue

When I use $point->Data()->ArcValue(strtotime("now"),rtAuto,null); I get below error:
Fatal error: Uncaught com_exception: Parameter 0: Type mismatch.in
C:\index3.php:58 Stack trace: #0 C:\index3.php(58):
variant->ArcValue(1625754415, 5, NULL)
#1 {main}thrown in C:\index3.php on line 58
How can I use the function ArcValue?
Seems like the time stamp is wrong.

Call to undefined function set_magic_quotes_runtime() [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
So, on my website I'm getting this error:
Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime() in /homepages/4/d661770438/htdocs/awptical/initdata.php:382 Stack trace: #0 /homepages/4/d661770438/htdocs/awptical/index.php(21): require_once() #1 {main} thrown in /homepages/4/d661770438/htdocs/awptical/initdata.php on line 382
Does anybody know what this means?
The function no longer exists in PHP 7, nor the setting it works with, so you will need to remove its usages. You will need to save the current state of your code and try to remove all the instances of this function call and see whether the site is working and if so, whether it is working as you expect it to work. Alternatively, you can implement a dummy version of the function and make it available everywhere:
if (!function_exists('set_magic_quotes_runtime')) {
function set_magic_quotes_runtime($new_setting) {
return true;
}
}
You are using PHP version 7.x.x, at which set_magic_quotes_runtime() was removed.
This function was DEPRECATED in PHP 5.3.0, and REMOVED as of PHP 7.0.0.

Problems printing array of XML [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have the following code that takes the "money" all my XML field but only 1 record and shows me this error:
Error:
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Start tag expected, '<' not found in /var/www/client/lib/class/index.php on line 34
Warning: SimpleXMLElement::__construct(): %PDF-1.4 in /var/www/client/lib/class/index.php on line 34
Warning: SimpleXMLElement::__construct(): ^ in /var/www/client/lib/class/index.php on line 34
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /var/www/client/lib/class/index.php:34 Stack trace: #0 /var/www/client/lib/class/index.php(34): SimpleXMLElement->__construct('%PDF-1.4?%?????...') #1 /var/www/client/lib/class/index.php(47): uuid->select() #2 {main} thrown in /var/www/client/lib/class/index.php on line 34
My code:
$data = $this -> conect -> conexion();
$dbquery = $data -> prepare("SELECT *
FROM FILE
ORDER BY ID
");
$dbquery->execute();
while($rows = $dbquery->fetch(PDO::FETCH_ASSOC)){
$string = $rows['BYTES'];
$tuxml = new SimpleXMLElement($string);
echo $tuxml->attributes()->Moneda;
Analysis
Reading the exception information properly reveals the origin of the problem:
Entity: line 1: parser error : Start tag expected, '<' not found
Conclusion: You try to parse something that is no valid XML
SimpleXMLElement->__construct('%PDF-1.4?%?????...')
Conclusion: Looks like you are trying to parse a PDF file as indicated by the magic number "%PDF":
Magic number(s):
All PDF files start with the characters '%PDF-' using the PDF
version number, e.g., '%PDF-1.4'. These characters are in US-
ASCII encoding.
(Source: RFC 3778, Page 9, https://www.rfc-editor.org/rfc/rfc3778)
Resolutions
Ensure your source contains only valid XML files
Try to detect the mime type of the file and skip non XML files
Add a surrounding try-catch block to handle files not parseable as XML

AWS S3 PHP getObject standard example causing fatal error

I have some code that looks exactly like this:
$result = $client->getObject(array(
'Bucket' => $bucket,
'Key' => 'data.txt',
'SaveAs' => '/tmp/data.txt'
));
its one of the examples listed here: http://docs.aws.amazon.com/aws-sdk-php-2/latest/class-Aws.S3.S3Client.html#_getObject
unfortunately I get this fatal error:
PHP Warning: Missing argument 2 for AmazonS3::get_object() in /var/www/CronJobs/aws-sdk- for-php/services/s3.class.php on line 1489
PHP Notice: Undefined variable: filename in /var/www/CronJobs/aws-sdk-for-php/services/s3.class.php on line 1495
PHP Warning: preg_match() expects parameter 2 to be string, array given in /var/www/CronJobs/aws-sdk-for-php/services/s3.class.php on line 1042
PHP Warning: preg_match() expects parameter 2 to be string, array given in /var/www/CronJobs/aws-sdk-for-php/services/s3.class.php on line 1043
PHP Notice: Array to string conversion in /var/www/CronJobs/aws-sdk-for-php/services/s3.class.php on line 548
PHP Fatal error: Uncaught exception 'S3_Exception' with message 'S3 does not support "Array" as a valid bucket name. Review "Bucket Restrictions and Limitations" in the S3 Developer Guide for more information.' in /var/www/CronJobs/aws-sdk-for-php/services/s3.class.php:548
Stack trace:
0 /var/www/CronJobs/aws-sdk-for-php/services/s3.class.php(1530): AmazonS3->authenticate(Array, Array)
1 [internal function]: AmazonS3->get_object(Array)
2 /var/www/CronJobs/aws-sdk-for-php/sdk.class.php(436): call_user_func_array(Array, Array)
3 /var/www/CronJobs/leefomatic/index.php(70): CFRuntime->__call('getObject', Array)
4 /var/www/CronJobs/leefomatic/index.php(70): AmazonS3->getObject(Array)
5 {main}
thrown in /var/www/CronJobs/aws-sdk-for-php/services/s3.class.php on line 548
in my script I am currently listObject, copy_object and delete_option just fine. Any thoughts as to why a fatal error comes up on a getObject?
Thanks.
It looks like you are using the SDK 2.x documentation with SDK 1.x code. The filenames (e.g., s3.class.php, sdk.class.php) output in the error block you have shown definitely indicate that you are using SDK 1.x code. You either need to install the newer and better supported SDK 2.x (here are some instructions), or use the SDK 1.x docs.

Categories