-1

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?

2
  • 1
    You can probably only run 1 statement at a time, you have 3. Commented Feb 6, 2014 at 0:21
  • As jeroen said, you can only run one at a time. But what's the point of setting variables you aren't using anyway? Commented Feb 6, 2014 at 0:27

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.