我的 php 更新查询不起作用
My php update query does not work
if(isset($_POST["trimite"]))
{
$nume=$_POST["nume"] ;
$prenume=$_POST["prenume"] ;
$bust=$_POST["bust"] ;
$talie=$_POST["talie"] ;
$sold=$_POST["sold"] ;
$par=$_POST["par"] ;
$img1=$_POST["imagine1"] ;
$img2=$_POST["imagine2"] ;
$img3=$_POST["imagine3"] ;
$idsal=$_POST["id_salariu"];
$id=$_GET["id"];
$update_query="UPDATE `model`
SET `nume` = '".$nume."'
AND `prenume` = '$prenume'
AND `bust` = $bust
AND `talie` = $talie
AND `sold` = $sold
AND `culoare_par` = '$par'
WHERE
`id_model`=$id";
$update_query1="UPDATE `poze`
SET `cale_poza` = '$img1'
AND `cale_poza1` = '$img2'
AND `cale_poza2` = '$img3'
WHERE
`id_model`=$id";
$update_query2="UPDATE `salariu`
SET `id_salariu` =$idsal
WHERE
`id_model`=$id";
echo 'MySQL server version: %s\n'. mysqli_get_server_info($connection);
$update=mysqli_query($connection, $update_query);
$update1=mysqli_query($connection, $update_query1);
$update2=mysqli_query($connection, $update_query2);
if ($update) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($connection);
}}
您好!
我在 phpMyAdmin 数据库中有这些列:nume(varchar), prenume(varchar), bust(int), talie(int),sold(int),par(varchar),cale_poza(varchar),cale_poza1(varchar),cale_poza2(varchar),id_salariu(int).
当我想在 phpMyAdmin 上运行这些查询时,它们有效,但是当我在 php 中运行它们时,它们不起作用。例如,当我想将 "nume" 字段从 "Prey" 更新为 "Prey1" 时,"nume" 字段将收到 0。当我尝试时,所有字段都收到相同的值更新。
提前谢谢!
更改您的 sql 查询并尝试
$update_query="UPDATE `model`
SET `nume` = '".$nume."'
,`prenume` = '$prenume'
,`bust` = $bust
,`talie` = $talie
,`sold` = $sold
,`culoare_par` = '$par'
WHERE
`id_model`=$id";
$update_query1="UPDATE `poze`
SET `cale_poza` = '$img1'
,`cale_poza1` = '$img2'
,`cale_poza2` = '$img3'
WHERE
`id_model`=$id";
if(isset($_POST["trimite"]))
{
$nume=$_POST["nume"] ;
$prenume=$_POST["prenume"] ;
$bust=$_POST["bust"] ;
$talie=$_POST["talie"] ;
$sold=$_POST["sold"] ;
$par=$_POST["par"] ;
$img1=$_POST["imagine1"] ;
$img2=$_POST["imagine2"] ;
$img3=$_POST["imagine3"] ;
$idsal=$_POST["id_salariu"];
$id=$_GET["id"];
$update_query="UPDATE `model`
SET `nume` = '".$nume."'
AND `prenume` = '$prenume'
AND `bust` = $bust
AND `talie` = $talie
AND `sold` = $sold
AND `culoare_par` = '$par'
WHERE
`id_model`=$id";
$update_query1="UPDATE `poze`
SET `cale_poza` = '$img1'
AND `cale_poza1` = '$img2'
AND `cale_poza2` = '$img3'
WHERE
`id_model`=$id";
$update_query2="UPDATE `salariu`
SET `id_salariu` =$idsal
WHERE
`id_model`=$id";
echo 'MySQL server version: %s\n'. mysqli_get_server_info($connection);
$update=mysqli_query($connection, $update_query);
$update1=mysqli_query($connection, $update_query1);
$update2=mysqli_query($connection, $update_query2);
if ($update) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($connection);
}}
您好!
我在 phpMyAdmin 数据库中有这些列:nume(varchar), prenume(varchar), bust(int), talie(int),sold(int),par(varchar),cale_poza(varchar),cale_poza1(varchar),cale_poza2(varchar),id_salariu(int).
当我想在 phpMyAdmin 上运行这些查询时,它们有效,但是当我在 php 中运行它们时,它们不起作用。例如,当我想将 "nume" 字段从 "Prey" 更新为 "Prey1" 时,"nume" 字段将收到 0。当我尝试时,所有字段都收到相同的值更新。 提前谢谢!
更改您的 sql 查询并尝试
$update_query="UPDATE `model`
SET `nume` = '".$nume."'
,`prenume` = '$prenume'
,`bust` = $bust
,`talie` = $talie
,`sold` = $sold
,`culoare_par` = '$par'
WHERE
`id_model`=$id";
$update_query1="UPDATE `poze`
SET `cale_poza` = '$img1'
,`cale_poza1` = '$img2'
,`cale_poza2` = '$img3'
WHERE
`id_model`=$id";