Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/271.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语法有错误;查看与您的MySQL服务器版本对应的手册,以了解使用near';更新_Php_Mysql_Syntax Error - Fatal编程技术网

Php 您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以了解使用near';更新

Php 您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以了解使用near';更新,php,mysql,syntax-error,Php,Mysql,Syntax Error,你好,我有一个用php运行的查询,它给出了一个错误 您的SQL语法有错误;查看与您的MySQL服务器版本相对应的手册,了解使用“update,note,stream_a”值附近(“”第2行)的正确语法 php代码: $logo = $_POST['logo']; $name = $_POST['name']; $content = $_POST['content']; $country = $_POST['country']; $satellite = $_POST[

你好,我有一个用php运行的查询,它给出了一个错误

您的SQL语法有错误;查看与您的MySQL服务器版本相对应的手册,了解使用“update,note,stream_a”值附近(“”第2行)的正确语法

php代码:

$logo      = $_POST['logo'];
$name      = $_POST['name'];
$content   = $_POST['content'];
$country   = $_POST['country'];
$satellite = $_POST['satellite'];
$position  = $_POST['position'];
$frequency = $_POST['frequency'];
$system    = $_POST['system'];
$fec       = $_POST['fec'];
$quality   = $_POST['quality'];
$lang      = $_POST['lang'];
$url_ch    = $_POST['url_ch'];
$stream    = $_POST['stream'];
$update    = $_POST['update'];
$note      = $_POST['note'];
$stream_a  = $_POST['stream_a'];
$id        = $_POST['id'];
$gpageid = intval($_GET['id']);


#######################

if(isset($_POST['add']) and $_POST['add'] == 'newch') {
    $addnewpage = mysql_query("insert into channels
    (logo,name,content,country,satellite,position,frequency,system,fec,quality,lang,url_ch,stream,update,note,stream_a)
    values
    ('$logo','$name','$content','$country','$satellite','$position','$frequency','$system','$fec','$quality','$lang','$url_ch','$stream','$update','$note','$stream_a')
    ") or die(mysql_error());
    if(isset($addnewpage )){
        die("
            <center>Done</center>
            <meta http-equiv='refresh' content='2; url=?cpages=channels' />
        ");
    }
}
$logo=$\u POST['logo'];
$name=$_POST['name'];
$content=$_POST['content'];
$country=$_POST['country'];
$satellite=$_POST['satellite'];
$position=$_POST['position'];
$frequency=$_POST['frequency'];
$system=$_POST['system'];
$fec=$_POST['fec'];
$quality=$_POST['quality'];
$lang=$_POST['lang'];
$url\u ch=$\u POST['url\u ch'];
$stream=$_POST['stream'];
$update=$_POST['update'];
$note=$_POST['note'];
$stream_a=$\u POST['stream_a'];
$id=$_POST['id'];
$gpageid=intval($_GET['id']);
#######################
如果(isset($_POST['add'])和$_POST['add']=='newch'){
$addnewpage=mysql\u查询(“插入通道
(徽标、名称、内容、国家、卫星、位置、频率、系统、fec、质量、语言、url\u ch、流、更新、注释、流)
价值观
(“$logo”、“$name”、“$content”、“$country”、“$satellite”、“$position”、“$frequency”、“$system”、“$fec”、“$quality”、“$lang”、“$url_ch”、“$stream”、“$update”、“$note”、“$stream_a”)
)或死亡(mysql_error());
如果(isset($addnewpage)){
死(”
多恩
");
}
}

update是SQL中的保留关键字,您需要在其周围加上勾号

...,stream,`update`,note,...

此外,由于mysql已被弃用,您应该在mysqli中编写此代码。因此,除非您当前的环境未设置为PHP5+版本,否则您需要学习mysqli函数。

update是SQL中的保留关键字,您需要在其周围加回记号,如“,”update“,但要加回记号,而不是”。此外,您应该在mysqli中编写此代码,因为mysql已被弃用,除非您当前的环境没有为PHP5+设置,否则您需要学习MySQLIDO不要浪费时间尝试学习传统的mysql扩展。它在几年前就被弃用了,并且从PHP/7开始就不再是语言的一部分。将查询输出到屏幕上,看看它是什么样子。此外,永远不要将post值放入查询。如果我提交了
”;作为名称从频道删除;
,会发生什么?在不处理$\u POST数据的情况下提出数据库请求可能会导致安全问题。您的代码容易受到攻击。您应该通过或驱动程序使用带绑定参数的预处理语句。有一些很好的示例。@BinSalem有一个数字在修复之前,您还需要解决其他一些严重问题。这只是其中之一。