简体   繁体   English

where子句中的SQL语法错误

[英]SQL Syntax error in where clause

I've been searching around and couldn't find a problem like mine. 我一直在搜索,找不到像我这样的问题。 I'm getting a syntax error, but no matter how i look at it, there doesn't seem to be anything wrong with it. 我遇到语法错误,但是无论我怎么看,似乎都没有错。

It goes like this: 它是这样的:

            <?php
    if(!empty($_POST['proj_id'])||!empty($_POST['task_uid']))
            die("Invalid proj_id or task_uid.");

        $query = "
        SELECT  pm.id,
                pm.proj_id,
                pm.task_uid,
                pp.pipeline_name,
                pm.proj_pipeline_order,
                pcrs.gestor_projeto,
                pcrs.prioridade,
                pcrs.tecnologia,
                pcrs.resp_programa

        FROM    projetos_main pm

        INNER JOIN projetos_pipeline pp
                  ON pm.task_uid = pp.task_uid

        RIGHT JOIN pcrs
                  ON pp.pcr = pcrs.num_doc

                 WHERE pm.proj_id = ".$_GET['proj_id']." 
                 AND pm.task_uid = ".$_GET['task_uid']."

            ";
        $result = mysql_query($query) or die(mysql_error());

        $row = mysql_fetch_array($result);

        $pipeline = $row ['pipeline_name'];
        $ordem = $row ['proj_pipeline_order'];
        $gestor = $row ['gestor_projetos'];
        $tecnologia = $row ['tecnologia'];
        $gestorPortfolio = $row['resp_programa'];
    ?>

is that where clause wrong? 那where子句错了吗? The dots are just to shorten the select. 点只是为了缩短选择。 I get the message 我收到消息

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND pm.task_uid =' at line 20" “您的SQL语法有误;请在与MySQL服务器版本相对应的手册中找到在第20行'AND pm.task_uid ='附近使用正确的语法”

it may be issue with quotes, try this 可能是引号有问题,请尝试此

SELECT  pm.id,
                pm.proj_id,
                pm.task_uid,
                .
                .
                .
                pcrs.resp_programa

        FROM    projetos_main pm

        INNER JOIN projetos_pipeline pp
                  ON pm.task_uid = pp.task_uid

        RIGHT JOIN pcrs
                  ON pp.pcr = pcrs.num_doc

                 WHERE pm.proj_id = '".$_POST['proj_id']."'
              AND pm.task_uid = '".$_POST['task_uid']."'

Also confirm existence of $_GET['task_uid' and $_GET['proj_uid'] 还要确认是否存在$ _GET ['task_uid'和$ _GET ['proj_uid']

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM