H
H
HAbRAhabp2015-10-15 06:46:16
PHP
HAbRAhabp, 2015-10-15 06:46:16

Why is Update not working?

For some reason UPDATE doesn't work. My function

$datenow = date("d F");
$limit1=mysql_query("select*from `limit1` where `date1`='$datenow'");
$limit2=mysql_fetch_array($limit1);
$limit3=$limit2['limitlimit'];
$result = mysql_query("SELECT *  FROM `limit1` WHERE `date1` = '$datenow'");
if(mysql_num_rows($result) < 1)
{
    mysql_query("INSERT INTO `limit1` SET `date1`='$datenow', `limitlimit`='0'");
}
if ($initOutput) {
       $withbalance = '1,05'
       $updatesum = $limit3 + $withbalance;
       echo $updatesum;
       mysql_query("UPDATE `limit1` SET `limitlimit`='$updatesum' where `date1`='$datenow'");
       echo mysql_errno($db) . ": " . mysql_error($link) . "\n";
}

The $updatesum variable itself is displayed normally. So the problem is in the record. Oddly enough, the same command through PMA is displayed normally.
DB structure:
CREATE TABLE IF NOT EXISTS `limit1` (
`id` int(11) NOT NULL,
  `date1` varchar(15) NOT NULL,
  `limitlimit` varchar(25) NOT NULL,
  `balance` varchar(10) NOT NULL DEFAULT '0'
) ENGINE=MyISAM AUTO_INCREMENT=32 DEFAULT CHARSET=utf8;
ALTER TABLE `limit1`
 ADD PRIMARY KEY (`id`);
ALTER TABLE `limit1`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT,AUTO_INCREMENT=32;

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Kubintsev, 2015-10-15
@HAbRAhabp

mysql_* functions should no longer work at all 8)
And if without laughter, then:
1) rewrite the code so that it is clear to you
2) replace mysql_* with PDO if possible or with mysqli_* extreme
3) install IDE and xdebug

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question