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?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top