Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php SQL命令不使用';不执行_Php_Mysql - Fatal编程技术网

Php SQL命令不使用';不执行

Php SQL命令不使用';不执行,php,mysql,Php,Mysql,我有简单的代码,我在其他文件中也使用过类似的模板,但似乎我就是不能让这一个工作( 问题是,第一个$sqlCommand执行得很好,之后其他任何一个都不起作用。即使用一些简单的sql语句替换了其余的代码(在第一个$sqlCommand之后),表也不会更新(与任何其他表相同).所有的特权都被授予了。我只是不知道这里出了什么问题…提前谢谢你的帮助 <?php $con = mysqli_connect("localhost","root","","moviegallary") or

我有简单的代码,我在其他文件中也使用过类似的模板,但似乎我就是不能让这一个工作( 问题是,第一个$sqlCommand执行得很好,之后其他任何一个都不起作用。即使用一些简单的sql语句替换了其余的代码(在第一个$sqlCommand之后),表也不会更新(与任何其他表相同).所有的特权都被授予了。我只是不知道这里出了什么问题…提前谢谢你的帮助

<?php
$con = mysqli_connect("localhost","root","","moviegallary")
       or die('Could not connect: '. mysqli_connect_error());
$sqlCommand = "update movie set title='$_GET[title2]', category='$_GET[category2]',   movieDesc='".mysql_real_escape_string($_GET['moviedesc2'])."',image='".mysql_real_escape_st ring($_GET['poster2'])."' where movieCode=$_GET[moviecode2];";

if (!mysqli_query($con,$sqlCommand))
{
    die ('Error: '.mysqli_error($con));
}
echo '<h1>1 record in "movie" table updated</h1>';

foreach ($_GET['new_star'] as $new_star)
{
    $query = mysqli_query($con,"select * from artist where concat(firstName,' ', lastName)='$new_star'");
    $count=mysqli_num_rows($query);
    if ($count>0) {
        $sqlCommand="insert into role select  $_GET[moviecode2], artistID from artist where concat(firstName,' ', lastName)='$new_star ;";
        echo '<h1>1 record in "role" table is inserted</h1>';
    }
}

mysqli_close($con);
?>

您没有执行
INSERT
语句

mysqli_query($con, $sqlCommand);

你需要开始使用准备好的语句,因为你的代码容易受到SQL注入攻击。

可爱的漏洞。享受你的服务器pwn3d。这更令人困惑,因为你在一个地方调用了mysqli_real_escape_string…警告你的代码容易受到SQL注入攻击。大概
mysql_real_escape_st string
只是一个粘贴g错误,而不是你的代码到底是什么?谢谢,我错过了mysqli_查询($con,$sqlCommand);但是对于最后一个,它仍然不起作用。在每次mysqli_查询之后,发现我只错过了一个引用。。很抱歉在这里发垃圾邮件)