Pre mysql输出与Phpmyadmin中处理的Update不同

时间:2011-11-17 19:19:42

标签: php mysql string phpmyadmin

$newInt = substr_replace($oldInt, $newDigit, $position, 1);
             $newValue = (string)$newInt;
            echo $newValue;

回显000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000    (我想要的!)

mysql_query("UPDATE table SET $fieldVariable = $newValue WHERE userID  = '".$_SESSION['userID']."' ")or die("Query failed:".mysql_error());

mysql记录显示 999999999999999999999999999999999999999999999999999

mysql字段设置为varchar(100)

2 个答案:

答案 0 :(得分:1)

在$ newValue周围添加引号,因为它是一个VARCHAR字段

mysql_query("UPDATE table SET $fieldVariable = '$newValue' WHERE userID  = '".$_SESSION['userID']."' ")or die("Query failed:".mysql_error());

答案 1 :(得分:0)

将$ newValue换成单引号'{$ newvalue}'