Jump to content
Sign in to follow this  

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?

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Create New...