dickybella85 Posted June 25, 2015 Share Posted June 25, 2015 A non well formed numeric value encountered please help me for this <?php $prix = number_format($prix, 2, '.', ' '); if($prix != 0) echo '<p class="p_prix_info_ann"><span class="vert">'. $language['page_ann_prix'] .' :</span> '. $param_gen['devise'] .' '. $prix .'</p>'; ?> Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted June 25, 2015 Share Posted June 25, 2015 I guess the error is from number_format()? The three lines you posted look ok. So it looks like $prix is not a number can you tell us how and where that variable is defined? Quote Link to comment Share on other sites More sharing options...
dickybella85 Posted June 25, 2015 Author Share Posted June 25, 2015 i change this code : <?phpif($prix != 0)echo '<p class="p_prix_info_ann"><span class="vert">'. $language['page_ann_prix'] .' :</span> '. $prix .' '. $param_gen['devise'] .'</p>';?> this for price format for 100,00$ to $100.00 Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted June 25, 2015 Share Posted June 25, 2015 Ok. Well those two lines would not produce that error. Its is the line with number_format() producing that error. It seems the value ($prix) you are giving number_format is not a number this why you are getting the error. How is $prix defined before that line? Quote Link to comment Share on other sites More sharing options...
dickybella85 Posted June 25, 2015 Author Share Posted June 25, 2015 $prix is for currency Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted June 25, 2015 Share Posted June 25, 2015 $prix is for currency Could you show us the code that defines $prix? Quote Link to comment Share on other sites More sharing options...
dickybella85 Posted June 25, 2015 Author Share Posted June 25, 2015 if i remove $prix my code not working Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted June 25, 2015 Share Posted June 25, 2015 For what it's worth, I was able to replicate the error with the following lines of code: $number = ' 234234234 '; print number_format($number, 2, '.', ' ') . '<br>'; The number_format() function doesn't seem to like spaces. Have you tried using var_dump() to see the exact value of $prix? Quote Link to comment Share on other sites More sharing options...
dickybella85 Posted June 25, 2015 Author Share Posted June 25, 2015 can you show me how to use var_dump()? im not expert about php code Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted June 25, 2015 Share Posted June 25, 2015 can you show me how to use var_dump()? var_dump($prix); More information about the function (including examples) can be found in the manual: http://php.net/manual/en/function.var-dump.php Quote Link to comment Share on other sites More sharing options...
dickybella85 Posted June 25, 2015 Author Share Posted June 25, 2015 like this? <?php $prix = number_format ($prix, 2, '.', ' '); var_dump($prix); if($prix != 0) echo '<p class="p_prix_info_ann"><span class="vert">'. $language['page_ann_prix'] .' :</span> '. $param_gen['devise'] .' '. $prix .'</p>'; ?> Quote Link to comment Share on other sites More sharing options...
dickybella85 Posted June 25, 2015 Author Share Posted June 25, 2015 now i getting this error A non well formed numeric value encountered in/home2/name/public_html/includes/functions_html.php on line 3158string(6) "120.00" Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted June 25, 2015 Share Posted June 25, 2015 Since the error seems to come from number_format(), you'll want to dump the variable before that function. Try this var_dump($prix); $prix = number_format ($prix, 2, '.', ' '); Quote Link to comment Share on other sites More sharing options...
dickybella85 Posted June 25, 2015 Author Share Posted June 25, 2015 get this A non well formed numeric value encountered in/home2/name/public_html/includes/functions_html.phpon line 3159 Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted June 25, 2015 Share Posted June 25, 2015 Hmm...so var_dump() doesn't output anything? But the number_format() function appears to be working with something since your last attempt with var_dump() displayed string(6) "120.00" Could you copy and paste the exact code you used? Quote Link to comment Share on other sites More sharing options...
Barand Posted June 25, 2015 Share Posted June 25, 2015 Good luck with that, cyberRobot. He's been asked several times already I guess the error is from number_format()? The three lines you posted look ok. So it looks like $prix is not a number can you tell us how and where that variable is defined? Ok. Well those two lines would not produce that error. Its is the line with number_format() producing that error. It seems the value ($prix) you are giving number_format is not a number this why you are getting the error. How is $prix defined before that line? Could you show us the code that defines $prix? Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted June 25, 2015 Share Posted June 25, 2015 get this A non well formed numeric value encountered in/home2/name/public_html/includes/functions_html.phpon line 3159 Just to clarify, did you move the var_dump() function before the call to number_format()? Or did you just remove var_dump() altogether? Quote Link to comment Share on other sites More sharing options...
martin27 Posted July 3, 2015 Share Posted July 3, 2015 $prix should be a numeric value which contains only numbers no special characters allowed. For example : $prix = 12345; not as $prix = $12345 $prix = number_format($prix, 2, '.', ' '); if($prix != 0) echo '<p class="p_prix_info_ann"><span class="vert">'. $language['page_ann_prix'] .' :</span> '. $param_gen['devise'] .' '. $prix .'</p>'; which gives : 12 345.00 when $prix is 12345 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.