View Single Post
Old 2014-02-14, 03:24   #10
WraithX's Avatar
Mar 2006

2·263 Posts

Originally Posted by daxmick View Post
Thanks for the info! Going with this idea I change my "while(1)" to while(is_resource($NumberToTest))" and then added a bit of code at the bottom of my script to print out what $NumberToTest is (I should only ever drop out of the while loop if $NumberToTest is no longer a gmp resource). And indeed I did get dropped out of the while loop and $NumberToTest prints out as "Resource id #-2147483648".
A couple of things to check would be, print out the value of both NumberToTest and Prime (perhaps both the value and the resource id) to see if one or both are having problems. Also, an example on the php website shows an extra check for empty rows before using the result of fetchArray. You can see that here:

Maybe your query is returning empty rows. To that point, maybe there are empty rows in your db? Try to look in your db to see if this may be the case. Or, maybe you should use fetchArray(SQLITE3_ASSOC) to guarantee you can call into the resultant array by string name 'thenumber'.

Also, can your gmp_cmp use the integer 0 as a value? Or should you be comparing against the string '0'? And, maybe the same thing for your gmp_add. Can you use the integer 1 as a value, or should that be the string value '1'?

I haven't programmed too much in PHP, but hopefully this will give you some things to look into to see if you can narrow down where the problem is coming from.
WraithX is offline   Reply With Quote