简体   繁体   English

该代码在phpmyadmin中键入时有效,但在我的网站上不起作用

[英]The code works when its typed in phpmyadmin but not working in my web site

The code work fine in the phpmyadmin but when i try to do it with php from the website it doesn't change the value :/ help !? 该代码在phpmyadmin中工作正常,但是当我尝试从网站上使用php进行操作时,它不会更改值:/ help!?

enter code here
<?php
    include_once 'logiranje.php';
    $maticen = $conn->real_escape_string($_POST['maticenpromena']);
    $naziv = $conn->real_escape_string($_POST['nazivsmetka']);
    if ($naziv=="Participacija") 
    {
        $naziv = "101010";
    }
    else if ($naziv=="Materijali") //problem here it was IF instead of ELSE IF
    {
        $naziv = "202020";
    }
    else
        $naziv = "303030";
    $mesec = $conn->real_escape_string($_POST['mesec']);
    $godina = $conn->real_escape_string($_POST['godina']);
    $sql = "UPDATE imaat SET imaat.platena=true WHERE imaat.embg=$maticen AND 
imaat.id_smetka= $naziv AND imaat.mesec=$mesec AND 
imaat.godina=$godina;";
mysqli_query($conn,$sql);
header("Location: ../smetki.php?platenasmetka=success");
?>

your sql is not correct, try with this: 您的sql不正确,请尝试以下操作:

$sql = "UPDATE imaat SET imaat.platena=true WHERE imaat.embg=".$maticen." AND 
imaat.id_smetka=". $naziv." AND imaat.mesec=".$mesec." AND 
imaat.godina=".$godina;

or 要么

$sql = "UPDATE imaat SET imaat.platena=true WHERE imaat.embg='$maticen' AND 
imaat.id_smetka='$naziv' AND imaat.mesec='$mesec' AND 
imaat.godina='$godina'";

when you insert $var inside your query , you are not put the value of variable , but the word $var that why , he can't find a row thoses variables names. 当您在查询中插入$ var时,不会将variable的值放进去,而是将$ var这个词放到为什么,他找不到那些变量名的行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 选择*,max(date)在phpMyAdmin中有效,但在我的代码中无效 - Select *, max(date) works in phpMyAdmin but not in my code 我在我的ubuntu上安装了phpmyadmin,但它没有用 - i install phpmyadmin on my ubuntu but its not working 为什么这个查询总是在phpmyadmin中运行,但在我的php pdo代码上它有时会起作用? - Why this query is always working in phpmyadmin but on my php pdo code it works sometimes? PHP我的查询在phpmyadmin中工作,但不在我的代码中 - PHP My query is working in phpmyadmin but not in my code SQL / PHP查询在PHPmyAdmin中有效,但在站点中无效 - SQL/PHP query works in PHPmyAdmin but not the site SQL 查询不起作用,但在 PHPMyAdmin 中有效 - SQL query not working but works in PHPMyAdmin 查询在 PHP 中不起作用,但在 phpmyadmin 中起作用 - Query not working in PHP but works in phpmyadmin 我的动态站点在站点在线时未加载,但在 localhost 中运行良好 - My dynamic site is not loading when the site is online but works well in localhost 我的用于将android应用程序连接到phpMyAdmin数据库的php代码不起作用 - My php code for connecting android application to phpMyAdmin database is not working 我的 Codeigniter 网站可以在本地主机上运行,但不能在 web 服务器上运行? 500 内部服务器 - My Codeigniter site works on localhost but not on web server? 500 internal server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM