where子句中的SQL语法错误

时间:2016-07-19 10:50:46

标签: php mysql

我一直在四处寻找并且找不到像我这样的问题。我收到语法错误,但不管我怎么看,它似乎都没有错。

它是这样的:

            <?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'];
    ?>

是where子句错了吗?点只是为了缩短选择。我收到了消息

  

&#34;您的SQL语法出错了;检查手册   对应于您的MySQL服务器版本,以便使用正确的语法   靠近&#39;和pm.task_uid =&#39;在第20行&#34;

1 个答案:

答案 0 :(得分:0)

引号可能有问题,试试这个

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']."'

同时确认$ _GET ['task_uid'和$ _GET ['proj_uid']

的存在