Jump to content

Non-numeric Value


Recommended Posts

Ok, so this is stemming from the fact that I can't get any output from PHP except errors when they occur (as described here) but since that doesn't seem to be an issue that's going to be resolved any time soon, I need to figure out how to work around it.  So, I split this issue (which I also posted in the linked thread) off into it's own separate thread to see if I can resolve this particular issue.

Anyway, I'm getting this error:
PHP Warning:  A non-numeric value encountered in ...filepath... on line 166

Line 166 looks like this:

$numPieces = ($Dim['bays']*$Dim['purlins'])*$Dim['qty'];

The error doesn't even tell me which of the three variables is throwing the error.  Normally, this wouldn't be an issue, because I'd just print out all the variables in the equation to see what they're being set to.  However, due to the previously mentioned issue, that's not possible.

So, I've tried to catch this error in the following ways:

try {
	$numPieces = ($Dim['bays']*$Dim['purlins'])*$Dim['qty'];
} catch (Throwable $e) {
	echo "<pre>".print_r($Dim, true)."</pre>";


$blnDump = false;
$which = '';
if (!is_numeric($Dim['bays'])) {
	$blnDump = true;
	$which = 'bays';
} elseif (!is_numeric($Dim['purlins'])) {
	$blnDump = true;
	$which = 'purlins';
} elseif (!is_numeric($Dim['qty'])) {
	$blnDump = true;
	$which = 'qty';
if ($blnDump)
	echo "$which was non-numeric:<br /><pre>".print_r($Dim, true)."</pre>";

but neither one catches the error and I just get the error printed on the page.  The error prints twice, because the code above is in a function that gets called multiple times within a loop, and the issue apparently is occurring on two different iterations of the loop.  And, because the code is in a loop, I can't use exit; or die(); to kill the script and print my debugging messages, because it kills the script on the first iteration of the loop.  As luck would have it, the first iteration is error free and is therefore unhelpful to say the least.

Please help?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...