Jump to content

simple problem!!


grlayouts

Recommended Posts



It also helps to set up the query as a string first so you can echo it if you have problems

[code]<?php
$sql = "update players set UTCQ=UTCQ+$drugupdate where id=$stat[id]";
mysql_query($sql) or die(mysql_error() . ' in <br>' . $sql);
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/34113-simple-problem/#findComment-160440
Share on other sites

Not using a WHERE clause will update all records, are you sure thats what you want? Try...

[code]
<?php
error_reporting(E_ALL) ; ini_set("display_errors","1");
include("config.php");
$drugupdate = 100 * '$stat[drugfact]';
$sql = "update players set UTCQ=UTCQ+'$drugupdate'";
mysql_query($sql) or die(mysql_error() . ' in <br>' . $sql);
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/34113-simple-problem/#findComment-160451
Share on other sites

Exactly.
I don't see why this wouldn't work:
[code]
<?php
error_reporting(E_ALL) ; ini_set("display_errors","1");
include("config.php");
$drugupdate = 100 * $stat['drugfact'];
$sql = "UPDATE players SET UTCQ=UTCQ+$drugupdate";
mysql_query($sql) or die(mysql_error() . ' in <br />' . $sql);
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/34113-simple-problem/#findComment-160460
Share on other sites

ok ive updated the code to include the $stat

[code]
<?php
include("config.php");
error_reporting(E_ALL) ; ini_set("display_errors","1");
$stat = mysql_fetch_array(mysql_query("select * from players"));
$drugupdate = 100 * $stat['drugfact'];
$sql = "UPDATE players SET UTCQ=UTCQ+$drugupdate";
mysql_query($sql) or die(mysql_error() . ' in <br />' . $sql);
?>
[/code]

still nothing updating?
Link to comment
https://forums.phpfreaks.com/topic/34113-simple-problem/#findComment-160464
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.