dongqigu0429 2014-02-06 00:17
浏览 40
已采纳

MySQL查询工作在phpmyadmin但不在PHP中

i've created a mysql view which is expecting 2 parameters and i'm able to query it without problems in phpyadmin with the following sql-string:

SET @date1 = '2014-02-06'; 
SET @date2 = '2014-02-07'; 
SELECT * FROM _myquery 

it will not work under php - i'm getting the following error:

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 'SET @date2 = '2014-02-07'; SELECT * FROM _myquery' at line 2

when it's working in phpmyadmin, shouldn't it also work under php? any idea what's wrong?

  • 写回答

1条回答 默认 最新

  • dongyupan4850 2014-02-06 00:28
    关注

    Do you really need the MySQL variables? because your SELECT query is not using them. You can try just with

    SELECT * FROM _myquery
    

    But if you really need to use MySQL variables, take a look at this:

    Mysql Variables not working through php mysql query

    MySql variables and php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程