php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16898 type convertation problem in pow()
Submitted: 2002-04-29 06:17 UTC Modified: 2002-05-30 00:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: sasha at xxi dot co dot il Assigned:
Status: No Feedback Package: *Math Functions
PHP Version: 4.2.0 OS: Linux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2002-04-29 06:17 UTC] sasha at xxi dot co dot il
$result=mysql_query("SELECT id, cdate FROM newspaper WHERE path='".substr($a, strrpos($a, "/")+1, strlen($a))."'") or die (mysql_error());
$rec=mysql_fetch_array($result);


$e=pow(2, $rec[id]); //Warning!


it's looks like what pow() function can't convert $rec[id] variable from string to integer automatically.
Using 

$rec[id]=stettype($rec[id], "int");

helps

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-29 06:28 UTC] mfischer@php.net
PHP automagically tries to convert the passed data to a number representation.

Please paste the exact values you are using to call this pow()
 [2002-05-06 22:12 UTC] dave at rowlands dot info
I have the same problem, but on windows xp.
The values are being selected back from mysql via ADODB. The values being used (in variables) are 2 and 0 eg pow($value1,$value2) where value1 = 2 and value2 = 0
 [2002-05-06 22:18 UTC] dave at rowlands dot info
Further to my last post, here is the code in question:

function NUM_HOLDS($level_hull)
{
  global $level_factor;
  return round(pow($level_factor, $level_hull) * 100);
}

as stated in the previous post, $level_factor = 2 and $level_hull = 0;

It also occurs on this line:

$shipspeed = pow($level_factor, $playerinfo[engines]);

Could it be because in my case, I am using an associative array as the second value?
 [2002-05-06 22:20 UTC] dave at rowlands dot info
This is a duplicate of 16944 which has been fixed.
 [2002-05-30 00:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Dec 05 12:03:38 2021 UTC