[英]About using update via mysqli
currently im so exhausted trying to figure why this function is not working as expected (inside a php class): 目前,我很疲惫,试图弄清楚为什么这个功能不能按预期工作(在php类中):
function actualizarPromos($nombre,$desc,$motivo,$id){
global $mysqli;
$sql="update promociones set nombre='".utf8_decode($nombre)."', desc='".utf8_decode($desc)."', motivo='".$motivo."' where id='".$id."'";
$mysqli->query($sql);
if($mysqli->insert_id>0){
//It saved the data
echo "Salvado";
}
else{
//It didn't save the data
echo "No salvado";
echo $mysqli->insert_id;
echo "<br>".$sql;
}
} }
I can´t get the function to update the contents of my db. 我无法获得更新数据库内容的功能。 I already tried to write de the SQL statement on phpmyadmin which is:
我已经尝试在phpmyadmin上编写de SQL语句,即:
update promociones set nombre='cumple', desc='muy buen cumple', motivo='mCumple' where id='13';
And it doesn't execute at all. 而且它根本不执行。 Anyone can help me out?.
有人可以帮我吗? Thanks in advance!
提前致谢!
desc
is a Revered Word in MySQL, so your query is most likely failing. desc
是MySQL中的崇敬词 ,因此您的查询很可能失败。 You need to escape it using the backtick - ` 您需要使用反引号将其转义-`
$sql="update promociones set nombre='".utf8_decode($nombre)."', `desc`='".utf8_decode($desc)."', motivo='".$motivo."' where id='".$id."'";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.