Warning: A non-numeric value encounteredWarning: A non-numeric value encountered inWarning: A non-numeric value encountered when upgrading to PHP 7.2why Am i getting Warning: A non-numeric value encountered in C:xampphtdocsoop_phfunction.php?Warning: A non-numeric value encountered in /templates/section-home.php on Line 34Wordpress Theme Fault, A non-numeric value encountered in PHP 7.2How to debug if a non-numeric value encounteredWarning: A non-numeric value encountered in handler.php on line 62Error: Warning: A non-numeric value encountered in php codeWarning: A non-numeric value encountered in D:xampphtdocsBoutiquecar.php on line 309WordPress theme error: A non-numeric value encountered in C:wamp64wwwwp-contentthemesretrotubetemp-style.php on line 16Reference — What does this symbol mean in PHP?Showing all errors and warningsA non well formed numeric value encounteredHow does PHP 'foreach' actually work?Reference - What does this error mean in PHP?A non-numeric value encountered in phpA non-numeric value encountered error in php 7.1 after upgrade wordpress coreWarning: A non-numeric value encountered inPHP Warning: A non-numeric value encounteredWarning: A non-numeric value encountered on line 234
Definition of Newton's first law
On what legal basis did the UK remove the 'European Union' from its passport?
How does Howard Stark know this?
Exclude loop* snap devices from lsblk output?
51% attack - apparently very easy? refering to CZ's "rollback btc chain" - How to make sure such corruptible scenario can never happen so easily?
Python Pandas Expand a Column of List of Lists to Two New Column
How can dragons propel their breath attacks to a long distance
What is Plautus’s pun about frustum and frustrum?
Can 'sudo apt-get remove [write]' destroy my Ubuntu?
What kind of SATA connector is this?
Why was castling bad for white in this game, and engine strongly prefered trading queens?
How are Core iX names like Core i5, i7 related to Haswell, Ivy Bridge?
Size of a folder with du
Was this character’s old age look CGI or make-up?
What is the significance of 4200 BCE in context of farming replacing foraging in Europe?
Two researchers want to work on the same extension to my paper. Who to help?
Can the sorting of a list be verified without comparing neighbors?
Light Switch Terminals
Drawing lines to nearest point
What's the difference between a Bunsen burner and a gas stove?
How to slow yourself down (for playing nice with others)
Create a list of all possible Boolean configurations of three constraints
Why was Thor doubtful about his worthiness to Mjolnir?
How can a layman easily get the consensus view of what academia *thinks* about a subject?
Warning: A non-numeric value encountered
Warning: A non-numeric value encountered inWarning: A non-numeric value encountered when upgrading to PHP 7.2why Am i getting Warning: A non-numeric value encountered in C:xampphtdocsoop_phfunction.php?Warning: A non-numeric value encountered in /templates/section-home.php on Line 34Wordpress Theme Fault, A non-numeric value encountered in PHP 7.2How to debug if a non-numeric value encounteredWarning: A non-numeric value encountered in handler.php on line 62Error: Warning: A non-numeric value encountered in php codeWarning: A non-numeric value encountered in D:xampphtdocsBoutiquecar.php on line 309WordPress theme error: A non-numeric value encountered in C:wamp64wwwwp-contentthemesretrotubetemp-style.php on line 16Reference — What does this symbol mean in PHP?Showing all errors and warningsA non well formed numeric value encounteredHow does PHP 'foreach' actually work?Reference - What does this error mean in PHP?A non-numeric value encountered in phpA non-numeric value encountered error in php 7.1 after upgrade wordpress coreWarning: A non-numeric value encountered inPHP Warning: A non-numeric value encounteredWarning: A non-numeric value encountered on line 234
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
Recently updated to PHP 7.1 and start getting following error
Warning: A non-numeric value encountered in on line 29
Here is what line 29 looks like
$sub_total += ($item['quantity'] * $product['price']);
On localhost all works fine..
Any ideas how to tackle this or what it is ?
php
add a comment |
Recently updated to PHP 7.1 and start getting following error
Warning: A non-numeric value encountered in on line 29
Here is what line 29 looks like
$sub_total += ($item['quantity'] * $product['price']);
On localhost all works fine..
Any ideas how to tackle this or what it is ?
php
3
var_dump($item['quantity'], $product['price'])
– u_mulder
Feb 4 '17 at 18:46
1
Looks like a new warning in PHP 7 (as you are aware). php.net/manual/en/migration71.other-changes.php When you get the error do those variables have values? I think you could avoid it by initializing them to 0.
– tjfo
Feb 4 '17 at 18:49
1
@MichaelHanon where is the answer you are referring to? what is the syntax error?
– FKEinternet
Nov 19 '17 at 9:02
$sub_total += ((int)$item['quantity'] * (int)$product['price']);
– I am the Most Stupid Person
Feb 26 '18 at 9:50
i use legacy format like this a=a+b; or str=str."<a href='".str2."'>asd</a>"; or $this->storeItems = $this->storeItems . $str;
– saber tabatabaee yazdi
May 26 '18 at 21:03
add a comment |
Recently updated to PHP 7.1 and start getting following error
Warning: A non-numeric value encountered in on line 29
Here is what line 29 looks like
$sub_total += ($item['quantity'] * $product['price']);
On localhost all works fine..
Any ideas how to tackle this or what it is ?
php
Recently updated to PHP 7.1 and start getting following error
Warning: A non-numeric value encountered in on line 29
Here is what line 29 looks like
$sub_total += ($item['quantity'] * $product['price']);
On localhost all works fine..
Any ideas how to tackle this or what it is ?
php
php
edited Feb 4 '17 at 20:25
Alexandre Neukirchen
2,07661529
2,07661529
asked Feb 4 '17 at 18:42
Imran RafiqueImran Rafique
4561512
4561512
3
var_dump($item['quantity'], $product['price'])
– u_mulder
Feb 4 '17 at 18:46
1
Looks like a new warning in PHP 7 (as you are aware). php.net/manual/en/migration71.other-changes.php When you get the error do those variables have values? I think you could avoid it by initializing them to 0.
– tjfo
Feb 4 '17 at 18:49
1
@MichaelHanon where is the answer you are referring to? what is the syntax error?
– FKEinternet
Nov 19 '17 at 9:02
$sub_total += ((int)$item['quantity'] * (int)$product['price']);
– I am the Most Stupid Person
Feb 26 '18 at 9:50
i use legacy format like this a=a+b; or str=str."<a href='".str2."'>asd</a>"; or $this->storeItems = $this->storeItems . $str;
– saber tabatabaee yazdi
May 26 '18 at 21:03
add a comment |
3
var_dump($item['quantity'], $product['price'])
– u_mulder
Feb 4 '17 at 18:46
1
Looks like a new warning in PHP 7 (as you are aware). php.net/manual/en/migration71.other-changes.php When you get the error do those variables have values? I think you could avoid it by initializing them to 0.
– tjfo
Feb 4 '17 at 18:49
1
@MichaelHanon where is the answer you are referring to? what is the syntax error?
– FKEinternet
Nov 19 '17 at 9:02
$sub_total += ((int)$item['quantity'] * (int)$product['price']);
– I am the Most Stupid Person
Feb 26 '18 at 9:50
i use legacy format like this a=a+b; or str=str."<a href='".str2."'>asd</a>"; or $this->storeItems = $this->storeItems . $str;
– saber tabatabaee yazdi
May 26 '18 at 21:03
3
3
var_dump($item['quantity'], $product['price'])
– u_mulder
Feb 4 '17 at 18:46
var_dump($item['quantity'], $product['price'])
– u_mulder
Feb 4 '17 at 18:46
1
1
Looks like a new warning in PHP 7 (as you are aware). php.net/manual/en/migration71.other-changes.php When you get the error do those variables have values? I think you could avoid it by initializing them to 0.
– tjfo
Feb 4 '17 at 18:49
Looks like a new warning in PHP 7 (as you are aware). php.net/manual/en/migration71.other-changes.php When you get the error do those variables have values? I think you could avoid it by initializing them to 0.
– tjfo
Feb 4 '17 at 18:49
1
1
@MichaelHanon where is the answer you are referring to? what is the syntax error?
– FKEinternet
Nov 19 '17 at 9:02
@MichaelHanon where is the answer you are referring to? what is the syntax error?
– FKEinternet
Nov 19 '17 at 9:02
$sub_total += ((int)$item['quantity'] * (int)$product['price']);
– I am the Most Stupid Person
Feb 26 '18 at 9:50
$sub_total += ((int)$item['quantity'] * (int)$product['price']);
– I am the Most Stupid Person
Feb 26 '18 at 9:50
i use legacy format like this a=a+b; or str=str."<a href='".str2."'>asd</a>"; or $this->storeItems = $this->storeItems . $str;
– saber tabatabaee yazdi
May 26 '18 at 21:03
i use legacy format like this a=a+b; or str=str."<a href='".str2."'>asd</a>"; or $this->storeItems = $this->storeItems . $str;
– saber tabatabaee yazdi
May 26 '18 at 21:03
add a comment |
14 Answers
14
active
oldest
votes
It seems that in PHP 7.1, a Warning will be emitted if a non-numeric value is encountered. See this link.
Here is the relevant portion that pertains to the Warning notice you are getting:
New E_WARNING and E_NOTICE errors have been introduced when invalid
strings are coerced using operators expecting numbers or their
assignment equivalents. An E_NOTICE is emitted when the string begins
with a numeric value but contains trailing non-numeric characters, and
an E_WARNING is emitted when the string does not contain a numeric
value.
I'm guessing either $item['quantity'] or $product['price'] does not contain a numeric value, so make sure that they do before trying to multiply them. Maybe use some sort of conditional before calculating the $sub_total, like so:
<?php
if (is_numeric($item['quantity']) && is_numeric($product['price']))
$sub_total += ($item['quantity'] * $product['price']);
else
// do some error handling...
2
I had this issue because I still had a few plus signs in the asp I was transferring to PHP. Ctrl+f and look for + characters.
– M H
Jun 15 '17 at 15:24
Is there a way to turn this warning off via php.ini?
– BeniRose
Aug 28 '17 at 16:49
@BeniRose The warning will only be thrown if your trying to apply math to non-numeric values, so if you try to multiply the strings 'cat' * '10', it will throw the error. If you try '10' * '10', you'll get no warning and the int 100. Turning this one off might be a bad idea I think. Here are a few links to PHP docs that may help you if you want to turn this off though. php.net/manual/en/… php.net/manual/en/configuration.file.php
– Daniel.Schroeder
Sep 2 '17 at 3:33
1
Thanks. I'm working on a legacy Symfony 1.4 project, and it seems there's a few places this happens intentionally, which has been a pain. This really should be a flag in php.ini that allows you to turn off this level of strictness.
– BeniRose
Sep 6 '17 at 16:16
3
Alternatively you can use$sub_total += ((int)$item['quantity'] * (int)$product['price']);
– I am the Most Stupid Person
Feb 13 '18 at 11:34
|
show 1 more comment
Not exactly the issue you had but the same error for people searching.
This happened to me when I spent too much time on JavaScript.
Coming back to PHP I concatenated two strings with "+
" instead of ".
" and got that error.
Crap I just scratched my head off and of course. I something like$a = "lorem" . $var-1 . "ipsum"
. Parenthesizing to$a = "lorem" . ($var-1) . "ipsum"
fixed it.
– namezero
Jan 9 at 16:36
2
This damn thing tripped me in 2019, LOL. PHP's string concatenation needs to be restructured!
– Dut A.
Jan 24 at 5:54
1
And here 2 weeks after doing nodejs and returning back to PHP I faced this error again lol
– imin
Feb 25 at 18:04
1
as soon as a string is being attempted to be concatenated with a+
, it's being assumed that it is anint
value... while the given operands aren't of any numeric data-type.
– Martin Zeitler
Mar 3 at 16:31
add a comment |
You can solve the problem without any new logic by just casting the thing into the number, which prevents the warning and is equivalent to the behavior in PHP 7.0 and below:
$sub_total += ((int)$item['quantity'] * (int)$product['price']);
(The answer from Daniel Schroeder is not equivalent because $sub_total would remain unset if non-numeric values are encountered. For example, if you print out $sub_total, you would get an empty string, which is probably wrong in an invoice. - by casting you make sure that $sub_total is an integer.)
1
that's a bad practice. You need to filter your inputs
– Ciro Vargas
May 25 '17 at 3:47
3
This seems to be the best answer. And for all you know these values are coming from the database, you may not need to escape.
– M H
Jun 15 '17 at 15:32
3
@Ciro Vargas: It depends on the application. In many cases you want an undefined integer to be interpreted as zero. Anyway this is the equivalent of the PHP7.0 behavior and does not require a rewrite of the code. (The accepted answer does require a rewrite.)
– Roland Seuhs
Jun 27 '17 at 12:24
@RolandSeuhs I'm not sure I follow, when multiplying two strings, '24' * '10' will produce 240 in PHP, '24' * null will produce 0, but '24' * 'cat' will throw the error mentioned above because 'cat' is a non-numeric value. You can cast 'cat' to an int, but that won't give you a meaningful subtotal either. As for my solution, it works for determining whether quantity and price are numeric. If they are strings '24' and '10', it passes, but if either is a non-numeric string, it fails. How sub_total gets dealt with was not really my aim, sorry if it came off that way.
– Daniel.Schroeder
Sep 2 '17 at 3:10
2
Just (int)$var fixed for me on php 7.1.8 thank you
– user5247236
Sep 10 '17 at 14:31
|
show 5 more comments
In my case it was because of me used "+" as in other language but in PHP strings concatenation oprator is "." .
add a comment |
This was happening to me specifically on PHPMyAdmin. So to more specifically answer this, I did the following:
In File:
C:amppsphpMyAdminlibrariesDisplayResults.class.php
I changed this:
// Move to the next page or to the last one
$endpos = $_SESSION['tmpval']['pos']
+ $_SESSION['tmpval']['max_rows'];
To this:
$endpos = 0;
if (!empty($_SESSION['tmpval']['pos']) && is_numeric($_SESSION['tmpval']['pos']))
$endpos += $_SESSION['tmpval']['pos'];
if (!empty($_SESSION['tmpval']['max_rows']) && is_numeric($_SESSION['tmpval']['max_rows']))
$endpos += $_SESSION['tmpval']['max_rows'];
Hope that save's someone some trouble...
add a comment |
I had this issue with my pagination forward and backward link .... simply set (int ) in front of the variable $Page+1 and it worked...
<?php
$Page = (isset($_GET['Page']) ? $_GET['Page'] : '');
if ((int)$Page+1<=$PostPagination)
?>
<li> <a href="Index.php?Page=<?php echo $Page+1; ?>"> »</a></li>
<?php
?>
add a comment |
Check if you're not incrementing with some variable that its value is an empty string like ''.
Example:
$total = '';
$integers = range(1, 5);
foreach($integers as $integer)
$total += $integer;
Super, this is a case missed in most of the other answers.
– Trendfischer
Feb 28 at 16:37
add a comment |
I encountered the issue in phpmyadmin with PHP 7.3. Thanks @coderama, I changed libraries/DisplayResults.class.php line 855 from
// Move to the next page or to the last one
$endpos = $_SESSION['tmpval']['pos']
+ $_SESSION['tmpval']['max_rows'];
into
// Move to the next page or to the last one
$endpos = (int)$_SESSION['tmpval']['pos']
+ (int)$_SESSION['tmpval']['max_rows'];
Fixed.
add a comment |
Try this.
$sub_total = 0;
and within your loop now you can use this
$sub_total += ($item['quantity'] * $product['price']);
It should solve your problem.
add a comment |
I just looked at this page as I had this issue. For me I had floating point numbers calculated from an array but even after designating the variables as floating points the error was still given, here's the simple fix and example code underneath which was causing the issue.
Example PHP
<?php
$subtotal = 0; //Warning fixed
$shippingtotal = 0; //Warning fixed
$price = array($row3['price']);
$shipping = array($row3['shipping']);
$values1 = array_sum($price);
$values2 = array_sum($shipping);
(float)$subtotal += $values1; // float is irrelevant $subtotal creates warning
(float)$shippingtotal += $values2; // float is irrelevant $shippingtotal creates warning
?>
add a comment |
$sn = 0;//increment the serial number, then add the sn to job
for($x = 0; $x<20; $x++)
$sn++;
$added_date = "10/10/10";
$job_title = "new job";
$salary = $sn*1000;
$cd = "27/10/2017";//the closing date
$ins = "some institution";//the institution for the vacancy
$notes = "some notes here";//any notes about the jobs
$sn_div = "<div class='sn_div'>".$sn."</div>";
$ad_div = "<div class='ad_div'>".$added_date."</div>";
$job_div = "<div class='job_div'>".$job_title."</div>";
$salary_div = "<div class='salary_div'>".$salary."</div>";
$cd_div = "<div class='cd_div'>".$cd."</div>";//cd means closing date
$ins_div = "<div class='ins_div'>".$ins."</div>";//ins means institution
$notes_div = "<div class='notes_div'>".$notes."</div>";
/*erroneous line*/$job_no = "job"+$sn;//to create the job rows
$$job_no = "<div class='job_wrapper'>".$sn_div.$ad_div.$job_div.$salary_div.$cd_div.$ins_div.$notes_div."</div>";
echo $$job_no;//and then echo each job
that's the code I had which looped and created new html div elements. The code worked fine and the elements were formed, but i got the same warning in the error_log.
After reading the useful other answers, I figured that I was summing up a string and a number in the erroneous line. So I changed the code at that line to
/*erroneous line*/$job_no = "job"&&$sn;//this is the new variable that will create the job rows
Now the code works as earlier but with no warnings this time. Hope this example would be useful to someone.
add a comment |
Solve this error on WordPress
Warning: A non-numeric value encountered in C:XAMPPhtdocsaad-2wp-includesSimplePieParseDate.php on line 694
Simple solution here!
- locate a file of
wp-includesSimplePieParseDate.php
- find a line no. 694
- you show the code
$second = round($match[6] + $match[7] / pow(10, strlen($match[7])));
- and change this 3.) to this line
$second = round((int)$match[6] + (int)$match[7] / pow(10, strlen($match[7])));
add a comment |
$sub_total_price = 0;
foreach($booking_list as $key=>$value)
$sub_total_price += ($price * $quantity);
echo $sub_total_price;
it's working 100% :)
add a comment |
That's happen usually when you con-cat strings with + sign. In PHP you can make concatenation using dot sign (.) So sometimes I accidentally put + sign between two strings in PHP, and it show me this error, since you can use + sign in numbers only.
add a comment |
protected by Obsidian Age Feb 10 at 20:46
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
14 Answers
14
active
oldest
votes
14 Answers
14
active
oldest
votes
active
oldest
votes
active
oldest
votes
It seems that in PHP 7.1, a Warning will be emitted if a non-numeric value is encountered. See this link.
Here is the relevant portion that pertains to the Warning notice you are getting:
New E_WARNING and E_NOTICE errors have been introduced when invalid
strings are coerced using operators expecting numbers or their
assignment equivalents. An E_NOTICE is emitted when the string begins
with a numeric value but contains trailing non-numeric characters, and
an E_WARNING is emitted when the string does not contain a numeric
value.
I'm guessing either $item['quantity'] or $product['price'] does not contain a numeric value, so make sure that they do before trying to multiply them. Maybe use some sort of conditional before calculating the $sub_total, like so:
<?php
if (is_numeric($item['quantity']) && is_numeric($product['price']))
$sub_total += ($item['quantity'] * $product['price']);
else
// do some error handling...
2
I had this issue because I still had a few plus signs in the asp I was transferring to PHP. Ctrl+f and look for + characters.
– M H
Jun 15 '17 at 15:24
Is there a way to turn this warning off via php.ini?
– BeniRose
Aug 28 '17 at 16:49
@BeniRose The warning will only be thrown if your trying to apply math to non-numeric values, so if you try to multiply the strings 'cat' * '10', it will throw the error. If you try '10' * '10', you'll get no warning and the int 100. Turning this one off might be a bad idea I think. Here are a few links to PHP docs that may help you if you want to turn this off though. php.net/manual/en/… php.net/manual/en/configuration.file.php
– Daniel.Schroeder
Sep 2 '17 at 3:33
1
Thanks. I'm working on a legacy Symfony 1.4 project, and it seems there's a few places this happens intentionally, which has been a pain. This really should be a flag in php.ini that allows you to turn off this level of strictness.
– BeniRose
Sep 6 '17 at 16:16
3
Alternatively you can use$sub_total += ((int)$item['quantity'] * (int)$product['price']);
– I am the Most Stupid Person
Feb 13 '18 at 11:34
|
show 1 more comment
It seems that in PHP 7.1, a Warning will be emitted if a non-numeric value is encountered. See this link.
Here is the relevant portion that pertains to the Warning notice you are getting:
New E_WARNING and E_NOTICE errors have been introduced when invalid
strings are coerced using operators expecting numbers or their
assignment equivalents. An E_NOTICE is emitted when the string begins
with a numeric value but contains trailing non-numeric characters, and
an E_WARNING is emitted when the string does not contain a numeric
value.
I'm guessing either $item['quantity'] or $product['price'] does not contain a numeric value, so make sure that they do before trying to multiply them. Maybe use some sort of conditional before calculating the $sub_total, like so:
<?php
if (is_numeric($item['quantity']) && is_numeric($product['price']))
$sub_total += ($item['quantity'] * $product['price']);
else
// do some error handling...
2
I had this issue because I still had a few plus signs in the asp I was transferring to PHP. Ctrl+f and look for + characters.
– M H
Jun 15 '17 at 15:24
Is there a way to turn this warning off via php.ini?
– BeniRose
Aug 28 '17 at 16:49
@BeniRose The warning will only be thrown if your trying to apply math to non-numeric values, so if you try to multiply the strings 'cat' * '10', it will throw the error. If you try '10' * '10', you'll get no warning and the int 100. Turning this one off might be a bad idea I think. Here are a few links to PHP docs that may help you if you want to turn this off though. php.net/manual/en/… php.net/manual/en/configuration.file.php
– Daniel.Schroeder
Sep 2 '17 at 3:33
1
Thanks. I'm working on a legacy Symfony 1.4 project, and it seems there's a few places this happens intentionally, which has been a pain. This really should be a flag in php.ini that allows you to turn off this level of strictness.
– BeniRose
Sep 6 '17 at 16:16
3
Alternatively you can use$sub_total += ((int)$item['quantity'] * (int)$product['price']);
– I am the Most Stupid Person
Feb 13 '18 at 11:34
|
show 1 more comment
It seems that in PHP 7.1, a Warning will be emitted if a non-numeric value is encountered. See this link.
Here is the relevant portion that pertains to the Warning notice you are getting:
New E_WARNING and E_NOTICE errors have been introduced when invalid
strings are coerced using operators expecting numbers or their
assignment equivalents. An E_NOTICE is emitted when the string begins
with a numeric value but contains trailing non-numeric characters, and
an E_WARNING is emitted when the string does not contain a numeric
value.
I'm guessing either $item['quantity'] or $product['price'] does not contain a numeric value, so make sure that they do before trying to multiply them. Maybe use some sort of conditional before calculating the $sub_total, like so:
<?php
if (is_numeric($item['quantity']) && is_numeric($product['price']))
$sub_total += ($item['quantity'] * $product['price']);
else
// do some error handling...
It seems that in PHP 7.1, a Warning will be emitted if a non-numeric value is encountered. See this link.
Here is the relevant portion that pertains to the Warning notice you are getting:
New E_WARNING and E_NOTICE errors have been introduced when invalid
strings are coerced using operators expecting numbers or their
assignment equivalents. An E_NOTICE is emitted when the string begins
with a numeric value but contains trailing non-numeric characters, and
an E_WARNING is emitted when the string does not contain a numeric
value.
I'm guessing either $item['quantity'] or $product['price'] does not contain a numeric value, so make sure that they do before trying to multiply them. Maybe use some sort of conditional before calculating the $sub_total, like so:
<?php
if (is_numeric($item['quantity']) && is_numeric($product['price']))
$sub_total += ($item['quantity'] * $product['price']);
else
// do some error handling...
answered Feb 4 '17 at 19:07
Daniel.SchroederDaniel.Schroeder
1,3921715
1,3921715
2
I had this issue because I still had a few plus signs in the asp I was transferring to PHP. Ctrl+f and look for + characters.
– M H
Jun 15 '17 at 15:24
Is there a way to turn this warning off via php.ini?
– BeniRose
Aug 28 '17 at 16:49
@BeniRose The warning will only be thrown if your trying to apply math to non-numeric values, so if you try to multiply the strings 'cat' * '10', it will throw the error. If you try '10' * '10', you'll get no warning and the int 100. Turning this one off might be a bad idea I think. Here are a few links to PHP docs that may help you if you want to turn this off though. php.net/manual/en/… php.net/manual/en/configuration.file.php
– Daniel.Schroeder
Sep 2 '17 at 3:33
1
Thanks. I'm working on a legacy Symfony 1.4 project, and it seems there's a few places this happens intentionally, which has been a pain. This really should be a flag in php.ini that allows you to turn off this level of strictness.
– BeniRose
Sep 6 '17 at 16:16
3
Alternatively you can use$sub_total += ((int)$item['quantity'] * (int)$product['price']);
– I am the Most Stupid Person
Feb 13 '18 at 11:34
|
show 1 more comment
2
I had this issue because I still had a few plus signs in the asp I was transferring to PHP. Ctrl+f and look for + characters.
– M H
Jun 15 '17 at 15:24
Is there a way to turn this warning off via php.ini?
– BeniRose
Aug 28 '17 at 16:49
@BeniRose The warning will only be thrown if your trying to apply math to non-numeric values, so if you try to multiply the strings 'cat' * '10', it will throw the error. If you try '10' * '10', you'll get no warning and the int 100. Turning this one off might be a bad idea I think. Here are a few links to PHP docs that may help you if you want to turn this off though. php.net/manual/en/… php.net/manual/en/configuration.file.php
– Daniel.Schroeder
Sep 2 '17 at 3:33
1
Thanks. I'm working on a legacy Symfony 1.4 project, and it seems there's a few places this happens intentionally, which has been a pain. This really should be a flag in php.ini that allows you to turn off this level of strictness.
– BeniRose
Sep 6 '17 at 16:16
3
Alternatively you can use$sub_total += ((int)$item['quantity'] * (int)$product['price']);
– I am the Most Stupid Person
Feb 13 '18 at 11:34
2
2
I had this issue because I still had a few plus signs in the asp I was transferring to PHP. Ctrl+f and look for + characters.
– M H
Jun 15 '17 at 15:24
I had this issue because I still had a few plus signs in the asp I was transferring to PHP. Ctrl+f and look for + characters.
– M H
Jun 15 '17 at 15:24
Is there a way to turn this warning off via php.ini?
– BeniRose
Aug 28 '17 at 16:49
Is there a way to turn this warning off via php.ini?
– BeniRose
Aug 28 '17 at 16:49
@BeniRose The warning will only be thrown if your trying to apply math to non-numeric values, so if you try to multiply the strings 'cat' * '10', it will throw the error. If you try '10' * '10', you'll get no warning and the int 100. Turning this one off might be a bad idea I think. Here are a few links to PHP docs that may help you if you want to turn this off though. php.net/manual/en/… php.net/manual/en/configuration.file.php
– Daniel.Schroeder
Sep 2 '17 at 3:33
@BeniRose The warning will only be thrown if your trying to apply math to non-numeric values, so if you try to multiply the strings 'cat' * '10', it will throw the error. If you try '10' * '10', you'll get no warning and the int 100. Turning this one off might be a bad idea I think. Here are a few links to PHP docs that may help you if you want to turn this off though. php.net/manual/en/… php.net/manual/en/configuration.file.php
– Daniel.Schroeder
Sep 2 '17 at 3:33
1
1
Thanks. I'm working on a legacy Symfony 1.4 project, and it seems there's a few places this happens intentionally, which has been a pain. This really should be a flag in php.ini that allows you to turn off this level of strictness.
– BeniRose
Sep 6 '17 at 16:16
Thanks. I'm working on a legacy Symfony 1.4 project, and it seems there's a few places this happens intentionally, which has been a pain. This really should be a flag in php.ini that allows you to turn off this level of strictness.
– BeniRose
Sep 6 '17 at 16:16
3
3
Alternatively you can use
$sub_total += ((int)$item['quantity'] * (int)$product['price']);
– I am the Most Stupid Person
Feb 13 '18 at 11:34
Alternatively you can use
$sub_total += ((int)$item['quantity'] * (int)$product['price']);
– I am the Most Stupid Person
Feb 13 '18 at 11:34
|
show 1 more comment
Not exactly the issue you had but the same error for people searching.
This happened to me when I spent too much time on JavaScript.
Coming back to PHP I concatenated two strings with "+
" instead of ".
" and got that error.
Crap I just scratched my head off and of course. I something like$a = "lorem" . $var-1 . "ipsum"
. Parenthesizing to$a = "lorem" . ($var-1) . "ipsum"
fixed it.
– namezero
Jan 9 at 16:36
2
This damn thing tripped me in 2019, LOL. PHP's string concatenation needs to be restructured!
– Dut A.
Jan 24 at 5:54
1
And here 2 weeks after doing nodejs and returning back to PHP I faced this error again lol
– imin
Feb 25 at 18:04
1
as soon as a string is being attempted to be concatenated with a+
, it's being assumed that it is anint
value... while the given operands aren't of any numeric data-type.
– Martin Zeitler
Mar 3 at 16:31
add a comment |
Not exactly the issue you had but the same error for people searching.
This happened to me when I spent too much time on JavaScript.
Coming back to PHP I concatenated two strings with "+
" instead of ".
" and got that error.
Crap I just scratched my head off and of course. I something like$a = "lorem" . $var-1 . "ipsum"
. Parenthesizing to$a = "lorem" . ($var-1) . "ipsum"
fixed it.
– namezero
Jan 9 at 16:36
2
This damn thing tripped me in 2019, LOL. PHP's string concatenation needs to be restructured!
– Dut A.
Jan 24 at 5:54
1
And here 2 weeks after doing nodejs and returning back to PHP I faced this error again lol
– imin
Feb 25 at 18:04
1
as soon as a string is being attempted to be concatenated with a+
, it's being assumed that it is anint
value... while the given operands aren't of any numeric data-type.
– Martin Zeitler
Mar 3 at 16:31
add a comment |
Not exactly the issue you had but the same error for people searching.
This happened to me when I spent too much time on JavaScript.
Coming back to PHP I concatenated two strings with "+
" instead of ".
" and got that error.
Not exactly the issue you had but the same error for people searching.
This happened to me when I spent too much time on JavaScript.
Coming back to PHP I concatenated two strings with "+
" instead of ".
" and got that error.
edited Jan 6 at 6:07
NullPoiиteя
46.3k19108128
46.3k19108128
answered May 19 '17 at 9:58
Yassir EnnazkYassir Ennazk
2,59322336
2,59322336
Crap I just scratched my head off and of course. I something like$a = "lorem" . $var-1 . "ipsum"
. Parenthesizing to$a = "lorem" . ($var-1) . "ipsum"
fixed it.
– namezero
Jan 9 at 16:36
2
This damn thing tripped me in 2019, LOL. PHP's string concatenation needs to be restructured!
– Dut A.
Jan 24 at 5:54
1
And here 2 weeks after doing nodejs and returning back to PHP I faced this error again lol
– imin
Feb 25 at 18:04
1
as soon as a string is being attempted to be concatenated with a+
, it's being assumed that it is anint
value... while the given operands aren't of any numeric data-type.
– Martin Zeitler
Mar 3 at 16:31
add a comment |
Crap I just scratched my head off and of course. I something like$a = "lorem" . $var-1 . "ipsum"
. Parenthesizing to$a = "lorem" . ($var-1) . "ipsum"
fixed it.
– namezero
Jan 9 at 16:36
2
This damn thing tripped me in 2019, LOL. PHP's string concatenation needs to be restructured!
– Dut A.
Jan 24 at 5:54
1
And here 2 weeks after doing nodejs and returning back to PHP I faced this error again lol
– imin
Feb 25 at 18:04
1
as soon as a string is being attempted to be concatenated with a+
, it's being assumed that it is anint
value... while the given operands aren't of any numeric data-type.
– Martin Zeitler
Mar 3 at 16:31
Crap I just scratched my head off and of course. I something like
$a = "lorem" . $var-1 . "ipsum"
. Parenthesizing to $a = "lorem" . ($var-1) . "ipsum"
fixed it.– namezero
Jan 9 at 16:36
Crap I just scratched my head off and of course. I something like
$a = "lorem" . $var-1 . "ipsum"
. Parenthesizing to $a = "lorem" . ($var-1) . "ipsum"
fixed it.– namezero
Jan 9 at 16:36
2
2
This damn thing tripped me in 2019, LOL. PHP's string concatenation needs to be restructured!
– Dut A.
Jan 24 at 5:54
This damn thing tripped me in 2019, LOL. PHP's string concatenation needs to be restructured!
– Dut A.
Jan 24 at 5:54
1
1
And here 2 weeks after doing nodejs and returning back to PHP I faced this error again lol
– imin
Feb 25 at 18:04
And here 2 weeks after doing nodejs and returning back to PHP I faced this error again lol
– imin
Feb 25 at 18:04
1
1
as soon as a string is being attempted to be concatenated with a
+
, it's being assumed that it is an int
value... while the given operands aren't of any numeric data-type.– Martin Zeitler
Mar 3 at 16:31
as soon as a string is being attempted to be concatenated with a
+
, it's being assumed that it is an int
value... while the given operands aren't of any numeric data-type.– Martin Zeitler
Mar 3 at 16:31
add a comment |
You can solve the problem without any new logic by just casting the thing into the number, which prevents the warning and is equivalent to the behavior in PHP 7.0 and below:
$sub_total += ((int)$item['quantity'] * (int)$product['price']);
(The answer from Daniel Schroeder is not equivalent because $sub_total would remain unset if non-numeric values are encountered. For example, if you print out $sub_total, you would get an empty string, which is probably wrong in an invoice. - by casting you make sure that $sub_total is an integer.)
1
that's a bad practice. You need to filter your inputs
– Ciro Vargas
May 25 '17 at 3:47
3
This seems to be the best answer. And for all you know these values are coming from the database, you may not need to escape.
– M H
Jun 15 '17 at 15:32
3
@Ciro Vargas: It depends on the application. In many cases you want an undefined integer to be interpreted as zero. Anyway this is the equivalent of the PHP7.0 behavior and does not require a rewrite of the code. (The accepted answer does require a rewrite.)
– Roland Seuhs
Jun 27 '17 at 12:24
@RolandSeuhs I'm not sure I follow, when multiplying two strings, '24' * '10' will produce 240 in PHP, '24' * null will produce 0, but '24' * 'cat' will throw the error mentioned above because 'cat' is a non-numeric value. You can cast 'cat' to an int, but that won't give you a meaningful subtotal either. As for my solution, it works for determining whether quantity and price are numeric. If they are strings '24' and '10', it passes, but if either is a non-numeric string, it fails. How sub_total gets dealt with was not really my aim, sorry if it came off that way.
– Daniel.Schroeder
Sep 2 '17 at 3:10
2
Just (int)$var fixed for me on php 7.1.8 thank you
– user5247236
Sep 10 '17 at 14:31
|
show 5 more comments
You can solve the problem without any new logic by just casting the thing into the number, which prevents the warning and is equivalent to the behavior in PHP 7.0 and below:
$sub_total += ((int)$item['quantity'] * (int)$product['price']);
(The answer from Daniel Schroeder is not equivalent because $sub_total would remain unset if non-numeric values are encountered. For example, if you print out $sub_total, you would get an empty string, which is probably wrong in an invoice. - by casting you make sure that $sub_total is an integer.)
1
that's a bad practice. You need to filter your inputs
– Ciro Vargas
May 25 '17 at 3:47
3
This seems to be the best answer. And for all you know these values are coming from the database, you may not need to escape.
– M H
Jun 15 '17 at 15:32
3
@Ciro Vargas: It depends on the application. In many cases you want an undefined integer to be interpreted as zero. Anyway this is the equivalent of the PHP7.0 behavior and does not require a rewrite of the code. (The accepted answer does require a rewrite.)
– Roland Seuhs
Jun 27 '17 at 12:24
@RolandSeuhs I'm not sure I follow, when multiplying two strings, '24' * '10' will produce 240 in PHP, '24' * null will produce 0, but '24' * 'cat' will throw the error mentioned above because 'cat' is a non-numeric value. You can cast 'cat' to an int, but that won't give you a meaningful subtotal either. As for my solution, it works for determining whether quantity and price are numeric. If they are strings '24' and '10', it passes, but if either is a non-numeric string, it fails. How sub_total gets dealt with was not really my aim, sorry if it came off that way.
– Daniel.Schroeder
Sep 2 '17 at 3:10
2
Just (int)$var fixed for me on php 7.1.8 thank you
– user5247236
Sep 10 '17 at 14:31
|
show 5 more comments
You can solve the problem without any new logic by just casting the thing into the number, which prevents the warning and is equivalent to the behavior in PHP 7.0 and below:
$sub_total += ((int)$item['quantity'] * (int)$product['price']);
(The answer from Daniel Schroeder is not equivalent because $sub_total would remain unset if non-numeric values are encountered. For example, if you print out $sub_total, you would get an empty string, which is probably wrong in an invoice. - by casting you make sure that $sub_total is an integer.)
You can solve the problem without any new logic by just casting the thing into the number, which prevents the warning and is equivalent to the behavior in PHP 7.0 and below:
$sub_total += ((int)$item['quantity'] * (int)$product['price']);
(The answer from Daniel Schroeder is not equivalent because $sub_total would remain unset if non-numeric values are encountered. For example, if you print out $sub_total, you would get an empty string, which is probably wrong in an invoice. - by casting you make sure that $sub_total is an integer.)
answered May 12 '17 at 7:11
Roland SeuhsRoland Seuhs
1,08241331
1,08241331
1
that's a bad practice. You need to filter your inputs
– Ciro Vargas
May 25 '17 at 3:47
3
This seems to be the best answer. And for all you know these values are coming from the database, you may not need to escape.
– M H
Jun 15 '17 at 15:32
3
@Ciro Vargas: It depends on the application. In many cases you want an undefined integer to be interpreted as zero. Anyway this is the equivalent of the PHP7.0 behavior and does not require a rewrite of the code. (The accepted answer does require a rewrite.)
– Roland Seuhs
Jun 27 '17 at 12:24
@RolandSeuhs I'm not sure I follow, when multiplying two strings, '24' * '10' will produce 240 in PHP, '24' * null will produce 0, but '24' * 'cat' will throw the error mentioned above because 'cat' is a non-numeric value. You can cast 'cat' to an int, but that won't give you a meaningful subtotal either. As for my solution, it works for determining whether quantity and price are numeric. If they are strings '24' and '10', it passes, but if either is a non-numeric string, it fails. How sub_total gets dealt with was not really my aim, sorry if it came off that way.
– Daniel.Schroeder
Sep 2 '17 at 3:10
2
Just (int)$var fixed for me on php 7.1.8 thank you
– user5247236
Sep 10 '17 at 14:31
|
show 5 more comments
1
that's a bad practice. You need to filter your inputs
– Ciro Vargas
May 25 '17 at 3:47
3
This seems to be the best answer. And for all you know these values are coming from the database, you may not need to escape.
– M H
Jun 15 '17 at 15:32
3
@Ciro Vargas: It depends on the application. In many cases you want an undefined integer to be interpreted as zero. Anyway this is the equivalent of the PHP7.0 behavior and does not require a rewrite of the code. (The accepted answer does require a rewrite.)
– Roland Seuhs
Jun 27 '17 at 12:24
@RolandSeuhs I'm not sure I follow, when multiplying two strings, '24' * '10' will produce 240 in PHP, '24' * null will produce 0, but '24' * 'cat' will throw the error mentioned above because 'cat' is a non-numeric value. You can cast 'cat' to an int, but that won't give you a meaningful subtotal either. As for my solution, it works for determining whether quantity and price are numeric. If they are strings '24' and '10', it passes, but if either is a non-numeric string, it fails. How sub_total gets dealt with was not really my aim, sorry if it came off that way.
– Daniel.Schroeder
Sep 2 '17 at 3:10
2
Just (int)$var fixed for me on php 7.1.8 thank you
– user5247236
Sep 10 '17 at 14:31
1
1
that's a bad practice. You need to filter your inputs
– Ciro Vargas
May 25 '17 at 3:47
that's a bad practice. You need to filter your inputs
– Ciro Vargas
May 25 '17 at 3:47
3
3
This seems to be the best answer. And for all you know these values are coming from the database, you may not need to escape.
– M H
Jun 15 '17 at 15:32
This seems to be the best answer. And for all you know these values are coming from the database, you may not need to escape.
– M H
Jun 15 '17 at 15:32
3
3
@Ciro Vargas: It depends on the application. In many cases you want an undefined integer to be interpreted as zero. Anyway this is the equivalent of the PHP7.0 behavior and does not require a rewrite of the code. (The accepted answer does require a rewrite.)
– Roland Seuhs
Jun 27 '17 at 12:24
@Ciro Vargas: It depends on the application. In many cases you want an undefined integer to be interpreted as zero. Anyway this is the equivalent of the PHP7.0 behavior and does not require a rewrite of the code. (The accepted answer does require a rewrite.)
– Roland Seuhs
Jun 27 '17 at 12:24
@RolandSeuhs I'm not sure I follow, when multiplying two strings, '24' * '10' will produce 240 in PHP, '24' * null will produce 0, but '24' * 'cat' will throw the error mentioned above because 'cat' is a non-numeric value. You can cast 'cat' to an int, but that won't give you a meaningful subtotal either. As for my solution, it works for determining whether quantity and price are numeric. If they are strings '24' and '10', it passes, but if either is a non-numeric string, it fails. How sub_total gets dealt with was not really my aim, sorry if it came off that way.
– Daniel.Schroeder
Sep 2 '17 at 3:10
@RolandSeuhs I'm not sure I follow, when multiplying two strings, '24' * '10' will produce 240 in PHP, '24' * null will produce 0, but '24' * 'cat' will throw the error mentioned above because 'cat' is a non-numeric value. You can cast 'cat' to an int, but that won't give you a meaningful subtotal either. As for my solution, it works for determining whether quantity and price are numeric. If they are strings '24' and '10', it passes, but if either is a non-numeric string, it fails. How sub_total gets dealt with was not really my aim, sorry if it came off that way.
– Daniel.Schroeder
Sep 2 '17 at 3:10
2
2
Just (int)$var fixed for me on php 7.1.8 thank you
– user5247236
Sep 10 '17 at 14:31
Just (int)$var fixed for me on php 7.1.8 thank you
– user5247236
Sep 10 '17 at 14:31
|
show 5 more comments
In my case it was because of me used "+" as in other language but in PHP strings concatenation oprator is "." .
add a comment |
In my case it was because of me used "+" as in other language but in PHP strings concatenation oprator is "." .
add a comment |
In my case it was because of me used "+" as in other language but in PHP strings concatenation oprator is "." .
In my case it was because of me used "+" as in other language but in PHP strings concatenation oprator is "." .
answered Feb 24 '18 at 10:25
CodeToLifeCodeToLife
1,1091818
1,1091818
add a comment |
add a comment |
This was happening to me specifically on PHPMyAdmin. So to more specifically answer this, I did the following:
In File:
C:amppsphpMyAdminlibrariesDisplayResults.class.php
I changed this:
// Move to the next page or to the last one
$endpos = $_SESSION['tmpval']['pos']
+ $_SESSION['tmpval']['max_rows'];
To this:
$endpos = 0;
if (!empty($_SESSION['tmpval']['pos']) && is_numeric($_SESSION['tmpval']['pos']))
$endpos += $_SESSION['tmpval']['pos'];
if (!empty($_SESSION['tmpval']['max_rows']) && is_numeric($_SESSION['tmpval']['max_rows']))
$endpos += $_SESSION['tmpval']['max_rows'];
Hope that save's someone some trouble...
add a comment |
This was happening to me specifically on PHPMyAdmin. So to more specifically answer this, I did the following:
In File:
C:amppsphpMyAdminlibrariesDisplayResults.class.php
I changed this:
// Move to the next page or to the last one
$endpos = $_SESSION['tmpval']['pos']
+ $_SESSION['tmpval']['max_rows'];
To this:
$endpos = 0;
if (!empty($_SESSION['tmpval']['pos']) && is_numeric($_SESSION['tmpval']['pos']))
$endpos += $_SESSION['tmpval']['pos'];
if (!empty($_SESSION['tmpval']['max_rows']) && is_numeric($_SESSION['tmpval']['max_rows']))
$endpos += $_SESSION['tmpval']['max_rows'];
Hope that save's someone some trouble...
add a comment |
This was happening to me specifically on PHPMyAdmin. So to more specifically answer this, I did the following:
In File:
C:amppsphpMyAdminlibrariesDisplayResults.class.php
I changed this:
// Move to the next page or to the last one
$endpos = $_SESSION['tmpval']['pos']
+ $_SESSION['tmpval']['max_rows'];
To this:
$endpos = 0;
if (!empty($_SESSION['tmpval']['pos']) && is_numeric($_SESSION['tmpval']['pos']))
$endpos += $_SESSION['tmpval']['pos'];
if (!empty($_SESSION['tmpval']['max_rows']) && is_numeric($_SESSION['tmpval']['max_rows']))
$endpos += $_SESSION['tmpval']['max_rows'];
Hope that save's someone some trouble...
This was happening to me specifically on PHPMyAdmin. So to more specifically answer this, I did the following:
In File:
C:amppsphpMyAdminlibrariesDisplayResults.class.php
I changed this:
// Move to the next page or to the last one
$endpos = $_SESSION['tmpval']['pos']
+ $_SESSION['tmpval']['max_rows'];
To this:
$endpos = 0;
if (!empty($_SESSION['tmpval']['pos']) && is_numeric($_SESSION['tmpval']['pos']))
$endpos += $_SESSION['tmpval']['pos'];
if (!empty($_SESSION['tmpval']['max_rows']) && is_numeric($_SESSION['tmpval']['max_rows']))
$endpos += $_SESSION['tmpval']['max_rows'];
Hope that save's someone some trouble...
answered Feb 27 '18 at 5:15
coderamacoderama
5,11635135268
5,11635135268
add a comment |
add a comment |
I had this issue with my pagination forward and backward link .... simply set (int ) in front of the variable $Page+1 and it worked...
<?php
$Page = (isset($_GET['Page']) ? $_GET['Page'] : '');
if ((int)$Page+1<=$PostPagination)
?>
<li> <a href="Index.php?Page=<?php echo $Page+1; ?>"> »</a></li>
<?php
?>
add a comment |
I had this issue with my pagination forward and backward link .... simply set (int ) in front of the variable $Page+1 and it worked...
<?php
$Page = (isset($_GET['Page']) ? $_GET['Page'] : '');
if ((int)$Page+1<=$PostPagination)
?>
<li> <a href="Index.php?Page=<?php echo $Page+1; ?>"> »</a></li>
<?php
?>
add a comment |
I had this issue with my pagination forward and backward link .... simply set (int ) in front of the variable $Page+1 and it worked...
<?php
$Page = (isset($_GET['Page']) ? $_GET['Page'] : '');
if ((int)$Page+1<=$PostPagination)
?>
<li> <a href="Index.php?Page=<?php echo $Page+1; ?>"> »</a></li>
<?php
?>
I had this issue with my pagination forward and backward link .... simply set (int ) in front of the variable $Page+1 and it worked...
<?php
$Page = (isset($_GET['Page']) ? $_GET['Page'] : '');
if ((int)$Page+1<=$PostPagination)
?>
<li> <a href="Index.php?Page=<?php echo $Page+1; ?>"> »</a></li>
<?php
?>
answered Apr 28 '18 at 16:29
bappibappi
693
693
add a comment |
add a comment |
Check if you're not incrementing with some variable that its value is an empty string like ''.
Example:
$total = '';
$integers = range(1, 5);
foreach($integers as $integer)
$total += $integer;
Super, this is a case missed in most of the other answers.
– Trendfischer
Feb 28 at 16:37
add a comment |
Check if you're not incrementing with some variable that its value is an empty string like ''.
Example:
$total = '';
$integers = range(1, 5);
foreach($integers as $integer)
$total += $integer;
Super, this is a case missed in most of the other answers.
– Trendfischer
Feb 28 at 16:37
add a comment |
Check if you're not incrementing with some variable that its value is an empty string like ''.
Example:
$total = '';
$integers = range(1, 5);
foreach($integers as $integer)
$total += $integer;
Check if you're not incrementing with some variable that its value is an empty string like ''.
Example:
$total = '';
$integers = range(1, 5);
foreach($integers as $integer)
$total += $integer;
answered Nov 21 '17 at 20:27
Luiz Gustavo MartinsLuiz Gustavo Martins
212
212
Super, this is a case missed in most of the other answers.
– Trendfischer
Feb 28 at 16:37
add a comment |
Super, this is a case missed in most of the other answers.
– Trendfischer
Feb 28 at 16:37
Super, this is a case missed in most of the other answers.
– Trendfischer
Feb 28 at 16:37
Super, this is a case missed in most of the other answers.
– Trendfischer
Feb 28 at 16:37
add a comment |
I encountered the issue in phpmyadmin with PHP 7.3. Thanks @coderama, I changed libraries/DisplayResults.class.php line 855 from
// Move to the next page or to the last one
$endpos = $_SESSION['tmpval']['pos']
+ $_SESSION['tmpval']['max_rows'];
into
// Move to the next page or to the last one
$endpos = (int)$_SESSION['tmpval']['pos']
+ (int)$_SESSION['tmpval']['max_rows'];
Fixed.
add a comment |
I encountered the issue in phpmyadmin with PHP 7.3. Thanks @coderama, I changed libraries/DisplayResults.class.php line 855 from
// Move to the next page or to the last one
$endpos = $_SESSION['tmpval']['pos']
+ $_SESSION['tmpval']['max_rows'];
into
// Move to the next page or to the last one
$endpos = (int)$_SESSION['tmpval']['pos']
+ (int)$_SESSION['tmpval']['max_rows'];
Fixed.
add a comment |
I encountered the issue in phpmyadmin with PHP 7.3. Thanks @coderama, I changed libraries/DisplayResults.class.php line 855 from
// Move to the next page or to the last one
$endpos = $_SESSION['tmpval']['pos']
+ $_SESSION['tmpval']['max_rows'];
into
// Move to the next page or to the last one
$endpos = (int)$_SESSION['tmpval']['pos']
+ (int)$_SESSION['tmpval']['max_rows'];
Fixed.
I encountered the issue in phpmyadmin with PHP 7.3. Thanks @coderama, I changed libraries/DisplayResults.class.php line 855 from
// Move to the next page or to the last one
$endpos = $_SESSION['tmpval']['pos']
+ $_SESSION['tmpval']['max_rows'];
into
// Move to the next page or to the last one
$endpos = (int)$_SESSION['tmpval']['pos']
+ (int)$_SESSION['tmpval']['max_rows'];
Fixed.
answered Nov 24 '18 at 17:40
HenryHenry
439515
439515
add a comment |
add a comment |
Try this.
$sub_total = 0;
and within your loop now you can use this
$sub_total += ($item['quantity'] * $product['price']);
It should solve your problem.
add a comment |
Try this.
$sub_total = 0;
and within your loop now you can use this
$sub_total += ($item['quantity'] * $product['price']);
It should solve your problem.
add a comment |
Try this.
$sub_total = 0;
and within your loop now you can use this
$sub_total += ($item['quantity'] * $product['price']);
It should solve your problem.
Try this.
$sub_total = 0;
and within your loop now you can use this
$sub_total += ($item['quantity'] * $product['price']);
It should solve your problem.
answered May 11 '17 at 22:09
WaddayWadday
314
314
add a comment |
add a comment |
I just looked at this page as I had this issue. For me I had floating point numbers calculated from an array but even after designating the variables as floating points the error was still given, here's the simple fix and example code underneath which was causing the issue.
Example PHP
<?php
$subtotal = 0; //Warning fixed
$shippingtotal = 0; //Warning fixed
$price = array($row3['price']);
$shipping = array($row3['shipping']);
$values1 = array_sum($price);
$values2 = array_sum($shipping);
(float)$subtotal += $values1; // float is irrelevant $subtotal creates warning
(float)$shippingtotal += $values2; // float is irrelevant $shippingtotal creates warning
?>
add a comment |
I just looked at this page as I had this issue. For me I had floating point numbers calculated from an array but even after designating the variables as floating points the error was still given, here's the simple fix and example code underneath which was causing the issue.
Example PHP
<?php
$subtotal = 0; //Warning fixed
$shippingtotal = 0; //Warning fixed
$price = array($row3['price']);
$shipping = array($row3['shipping']);
$values1 = array_sum($price);
$values2 = array_sum($shipping);
(float)$subtotal += $values1; // float is irrelevant $subtotal creates warning
(float)$shippingtotal += $values2; // float is irrelevant $shippingtotal creates warning
?>
add a comment |
I just looked at this page as I had this issue. For me I had floating point numbers calculated from an array but even after designating the variables as floating points the error was still given, here's the simple fix and example code underneath which was causing the issue.
Example PHP
<?php
$subtotal = 0; //Warning fixed
$shippingtotal = 0; //Warning fixed
$price = array($row3['price']);
$shipping = array($row3['shipping']);
$values1 = array_sum($price);
$values2 = array_sum($shipping);
(float)$subtotal += $values1; // float is irrelevant $subtotal creates warning
(float)$shippingtotal += $values2; // float is irrelevant $shippingtotal creates warning
?>
I just looked at this page as I had this issue. For me I had floating point numbers calculated from an array but even after designating the variables as floating points the error was still given, here's the simple fix and example code underneath which was causing the issue.
Example PHP
<?php
$subtotal = 0; //Warning fixed
$shippingtotal = 0; //Warning fixed
$price = array($row3['price']);
$shipping = array($row3['shipping']);
$values1 = array_sum($price);
$values2 = array_sum($shipping);
(float)$subtotal += $values1; // float is irrelevant $subtotal creates warning
(float)$shippingtotal += $values2; // float is irrelevant $shippingtotal creates warning
?>
answered Nov 28 '17 at 0:05
user5340092
add a comment |
add a comment |
$sn = 0;//increment the serial number, then add the sn to job
for($x = 0; $x<20; $x++)
$sn++;
$added_date = "10/10/10";
$job_title = "new job";
$salary = $sn*1000;
$cd = "27/10/2017";//the closing date
$ins = "some institution";//the institution for the vacancy
$notes = "some notes here";//any notes about the jobs
$sn_div = "<div class='sn_div'>".$sn."</div>";
$ad_div = "<div class='ad_div'>".$added_date."</div>";
$job_div = "<div class='job_div'>".$job_title."</div>";
$salary_div = "<div class='salary_div'>".$salary."</div>";
$cd_div = "<div class='cd_div'>".$cd."</div>";//cd means closing date
$ins_div = "<div class='ins_div'>".$ins."</div>";//ins means institution
$notes_div = "<div class='notes_div'>".$notes."</div>";
/*erroneous line*/$job_no = "job"+$sn;//to create the job rows
$$job_no = "<div class='job_wrapper'>".$sn_div.$ad_div.$job_div.$salary_div.$cd_div.$ins_div.$notes_div."</div>";
echo $$job_no;//and then echo each job
that's the code I had which looped and created new html div elements. The code worked fine and the elements were formed, but i got the same warning in the error_log.
After reading the useful other answers, I figured that I was summing up a string and a number in the erroneous line. So I changed the code at that line to
/*erroneous line*/$job_no = "job"&&$sn;//this is the new variable that will create the job rows
Now the code works as earlier but with no warnings this time. Hope this example would be useful to someone.
add a comment |
$sn = 0;//increment the serial number, then add the sn to job
for($x = 0; $x<20; $x++)
$sn++;
$added_date = "10/10/10";
$job_title = "new job";
$salary = $sn*1000;
$cd = "27/10/2017";//the closing date
$ins = "some institution";//the institution for the vacancy
$notes = "some notes here";//any notes about the jobs
$sn_div = "<div class='sn_div'>".$sn."</div>";
$ad_div = "<div class='ad_div'>".$added_date."</div>";
$job_div = "<div class='job_div'>".$job_title."</div>";
$salary_div = "<div class='salary_div'>".$salary."</div>";
$cd_div = "<div class='cd_div'>".$cd."</div>";//cd means closing date
$ins_div = "<div class='ins_div'>".$ins."</div>";//ins means institution
$notes_div = "<div class='notes_div'>".$notes."</div>";
/*erroneous line*/$job_no = "job"+$sn;//to create the job rows
$$job_no = "<div class='job_wrapper'>".$sn_div.$ad_div.$job_div.$salary_div.$cd_div.$ins_div.$notes_div."</div>";
echo $$job_no;//and then echo each job
that's the code I had which looped and created new html div elements. The code worked fine and the elements were formed, but i got the same warning in the error_log.
After reading the useful other answers, I figured that I was summing up a string and a number in the erroneous line. So I changed the code at that line to
/*erroneous line*/$job_no = "job"&&$sn;//this is the new variable that will create the job rows
Now the code works as earlier but with no warnings this time. Hope this example would be useful to someone.
add a comment |
$sn = 0;//increment the serial number, then add the sn to job
for($x = 0; $x<20; $x++)
$sn++;
$added_date = "10/10/10";
$job_title = "new job";
$salary = $sn*1000;
$cd = "27/10/2017";//the closing date
$ins = "some institution";//the institution for the vacancy
$notes = "some notes here";//any notes about the jobs
$sn_div = "<div class='sn_div'>".$sn."</div>";
$ad_div = "<div class='ad_div'>".$added_date."</div>";
$job_div = "<div class='job_div'>".$job_title."</div>";
$salary_div = "<div class='salary_div'>".$salary."</div>";
$cd_div = "<div class='cd_div'>".$cd."</div>";//cd means closing date
$ins_div = "<div class='ins_div'>".$ins."</div>";//ins means institution
$notes_div = "<div class='notes_div'>".$notes."</div>";
/*erroneous line*/$job_no = "job"+$sn;//to create the job rows
$$job_no = "<div class='job_wrapper'>".$sn_div.$ad_div.$job_div.$salary_div.$cd_div.$ins_div.$notes_div."</div>";
echo $$job_no;//and then echo each job
that's the code I had which looped and created new html div elements. The code worked fine and the elements were formed, but i got the same warning in the error_log.
After reading the useful other answers, I figured that I was summing up a string and a number in the erroneous line. So I changed the code at that line to
/*erroneous line*/$job_no = "job"&&$sn;//this is the new variable that will create the job rows
Now the code works as earlier but with no warnings this time. Hope this example would be useful to someone.
$sn = 0;//increment the serial number, then add the sn to job
for($x = 0; $x<20; $x++)
$sn++;
$added_date = "10/10/10";
$job_title = "new job";
$salary = $sn*1000;
$cd = "27/10/2017";//the closing date
$ins = "some institution";//the institution for the vacancy
$notes = "some notes here";//any notes about the jobs
$sn_div = "<div class='sn_div'>".$sn."</div>";
$ad_div = "<div class='ad_div'>".$added_date."</div>";
$job_div = "<div class='job_div'>".$job_title."</div>";
$salary_div = "<div class='salary_div'>".$salary."</div>";
$cd_div = "<div class='cd_div'>".$cd."</div>";//cd means closing date
$ins_div = "<div class='ins_div'>".$ins."</div>";//ins means institution
$notes_div = "<div class='notes_div'>".$notes."</div>";
/*erroneous line*/$job_no = "job"+$sn;//to create the job rows
$$job_no = "<div class='job_wrapper'>".$sn_div.$ad_div.$job_div.$salary_div.$cd_div.$ins_div.$notes_div."</div>";
echo $$job_no;//and then echo each job
that's the code I had which looped and created new html div elements. The code worked fine and the elements were formed, but i got the same warning in the error_log.
After reading the useful other answers, I figured that I was summing up a string and a number in the erroneous line. So I changed the code at that line to
/*erroneous line*/$job_no = "job"&&$sn;//this is the new variable that will create the job rows
Now the code works as earlier but with no warnings this time. Hope this example would be useful to someone.
answered Nov 28 '17 at 3:00
NeoNeo
367212
367212
add a comment |
add a comment |
Solve this error on WordPress
Warning: A non-numeric value encountered in C:XAMPPhtdocsaad-2wp-includesSimplePieParseDate.php on line 694
Simple solution here!
- locate a file of
wp-includesSimplePieParseDate.php
- find a line no. 694
- you show the code
$second = round($match[6] + $match[7] / pow(10, strlen($match[7])));
- and change this 3.) to this line
$second = round((int)$match[6] + (int)$match[7] / pow(10, strlen($match[7])));
add a comment |
Solve this error on WordPress
Warning: A non-numeric value encountered in C:XAMPPhtdocsaad-2wp-includesSimplePieParseDate.php on line 694
Simple solution here!
- locate a file of
wp-includesSimplePieParseDate.php
- find a line no. 694
- you show the code
$second = round($match[6] + $match[7] / pow(10, strlen($match[7])));
- and change this 3.) to this line
$second = round((int)$match[6] + (int)$match[7] / pow(10, strlen($match[7])));
add a comment |
Solve this error on WordPress
Warning: A non-numeric value encountered in C:XAMPPhtdocsaad-2wp-includesSimplePieParseDate.php on line 694
Simple solution here!
- locate a file of
wp-includesSimplePieParseDate.php
- find a line no. 694
- you show the code
$second = round($match[6] + $match[7] / pow(10, strlen($match[7])));
- and change this 3.) to this line
$second = round((int)$match[6] + (int)$match[7] / pow(10, strlen($match[7])));
Solve this error on WordPress
Warning: A non-numeric value encountered in C:XAMPPhtdocsaad-2wp-includesSimplePieParseDate.php on line 694
Simple solution here!
- locate a file of
wp-includesSimplePieParseDate.php
- find a line no. 694
- you show the code
$second = round($match[6] + $match[7] / pow(10, strlen($match[7])));
- and change this 3.) to this line
$second = round((int)$match[6] + (int)$match[7] / pow(10, strlen($match[7])));
edited Feb 16 '18 at 14:00
slavoo
4,018122936
4,018122936
answered Feb 16 '18 at 13:37
Nasirkhan PathanNasirkhan Pathan
115
115
add a comment |
add a comment |
$sub_total_price = 0;
foreach($booking_list as $key=>$value)
$sub_total_price += ($price * $quantity);
echo $sub_total_price;
it's working 100% :)
add a comment |
$sub_total_price = 0;
foreach($booking_list as $key=>$value)
$sub_total_price += ($price * $quantity);
echo $sub_total_price;
it's working 100% :)
add a comment |
$sub_total_price = 0;
foreach($booking_list as $key=>$value)
$sub_total_price += ($price * $quantity);
echo $sub_total_price;
it's working 100% :)
$sub_total_price = 0;
foreach($booking_list as $key=>$value)
$sub_total_price += ($price * $quantity);
echo $sub_total_price;
it's working 100% :)
edited Apr 24 '18 at 7:21
Pankaj Makwana
2,55561942
2,55561942
answered Apr 24 '18 at 7:01
Imran ImuImran Imu
111
111
add a comment |
add a comment |
That's happen usually when you con-cat strings with + sign. In PHP you can make concatenation using dot sign (.) So sometimes I accidentally put + sign between two strings in PHP, and it show me this error, since you can use + sign in numbers only.
add a comment |
That's happen usually when you con-cat strings with + sign. In PHP you can make concatenation using dot sign (.) So sometimes I accidentally put + sign between two strings in PHP, and it show me this error, since you can use + sign in numbers only.
add a comment |
That's happen usually when you con-cat strings with + sign. In PHP you can make concatenation using dot sign (.) So sometimes I accidentally put + sign between two strings in PHP, and it show me this error, since you can use + sign in numbers only.
That's happen usually when you con-cat strings with + sign. In PHP you can make concatenation using dot sign (.) So sometimes I accidentally put + sign between two strings in PHP, and it show me this error, since you can use + sign in numbers only.
answered Jul 22 '18 at 0:08
ASammourASammour
26727
26727
add a comment |
add a comment |
protected by Obsidian Age Feb 10 at 20:46
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
3
var_dump($item['quantity'], $product['price'])
– u_mulder
Feb 4 '17 at 18:46
1
Looks like a new warning in PHP 7 (as you are aware). php.net/manual/en/migration71.other-changes.php When you get the error do those variables have values? I think you could avoid it by initializing them to 0.
– tjfo
Feb 4 '17 at 18:49
1
@MichaelHanon where is the answer you are referring to? what is the syntax error?
– FKEinternet
Nov 19 '17 at 9:02
$sub_total += ((int)$item['quantity'] * (int)$product['price']);
– I am the Most Stupid Person
Feb 26 '18 at 9:50
i use legacy format like this a=a+b; or str=str."<a href='".str2."'>asd</a>"; or $this->storeItems = $this->storeItems . $str;
– saber tabatabaee yazdi
May 26 '18 at 21:03