Home  >  Article  >  Backend Development  >  What should I do if the PHP update statement fails to execute?

What should I do if the PHP update statement fails to execute?

藏色散人
藏色散人Original
2022-12-01 09:43:425941browse

Solution to the failure of php update statement execution: 1. Open the corresponding PHP file; 2. Find the "update set name='1231' from xsb where sex= '...'" statement; 3. Modify The update statement is "update set from xsb name='1231' where sex= '...'".

What should I do if the PHP update statement fails to execute?

The operating environment of this tutorial: Windows 7 system, PHP version 8.1, Dell G3 computer.

What should I do if the PHP update statement fails to execute?

Specific problem description:

php update statement cannot be executed

<?
$con=mysql_connect(&#39;localhost&#39;,&#39;root&#39;,&#39;1&#39;) or die(&#39;连接失败&#39;);
mysql_select_db(&#39;xsxx1&#39;,$con) or die(&#39;选择数据库失败&#39;);
mysql_query("SET NAMES gb2312");
$updatesql="update set name=&#39;1231&#39; from xsb where sex= &#39;女&#39; ";
$update = mysql_query($updatesql,$con);
// 检测修改操作是否成功
if ($update){
echo "修改记录成功!";
echo "<br>";
}
else
{
echo "修改记录失败!";
echo "<br>";
}
?>

This is the code I wrote, it always fails. why?

Solution to the problem:

update set name=&#39;1231&#39; from xsb where sex= &#39;女&#39;

is changed to

update set from xsb name=&#39;1231&#39; where sex= &#39;女&#39;

Recommended study: "PHP Video Tutorial"

The above is the detailed content of What should I do if the PHP update statement fails to execute?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn