Jump to content

Math problem


Ifa

Recommended Posts

try it without the single quotes, since you're dealing with adding integers. as for the difference between browsers, that doesn't make much sense to me, since the math is being handled by the server. is the variable being populated from a form field, or when you run the code just as you have it, is it off? next question: why do you have a FROM clause in an update statment? what are you trying to do? shouldn't it be a WHERE?
[code]
<?php
$var = 1;
mysql_query("UPDATE tableName SET var = var + $var WHERE something = something");
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/18897-math-problem/#findComment-81616
Share on other sites

Oops, your right about the from, I use where, I just wrote the code as an example and made a tiny mistake :)

No, the data isn't coming from a form, it's a number that is increased in a loop. But thanks, I'll try it without no single quotes. I can test it now though, as I'm at work, and all this comp has is IE...

To be more spesific, the number is a calculation actually, $var = round($var2 / $var3, 0);
Link to comment
https://forums.phpfreaks.com/topic/18897-math-problem/#findComment-81620
Share on other sites

This is getting funny:
$var = $var2 + 10;
mysql_query("UPDATE table SET var = $var WHERE some=thing ") or die('Query failed: ' . mysql_error());
echo $var;

the echo returns 16, but the update makes it 18... And though it seems extremely odd, IE just makes it right, and firefox doesn't. So much for it being a serverside language ;)

$var2 = -1 * round(($var3 * $var4) / $var5, 0);

Oh and with  or without ' ' seems to make no diffrence...
Link to comment
https://forums.phpfreaks.com/topic/18897-math-problem/#findComment-82484
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.