Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] query with variables
#1

[eluser]predat0r[/eluser]
Hi, i get a 1064 parse error at the last line. I found and tried several method but not find the right solution. Maybe the parameters has different types?

Code:
function get_articles($year, $month)
{
$query = $this->db->query("SELECT id, title, preview, SUBSTRING('date', 1, 4) as year, SUBSTRING('date', 6, 2) as month, seo_title
FROM articles
WHERE year ='".$year."' AND
WHERE month ='".$month."'");    
...
}

Error Number: 1064

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 'WHERE honap ='05'' at line 4

SELECT id, title, preview, SUBSTRING('date', 1, 4) as year, SUBSTRING('date', 6, 2) as month, seo_title FROM articles WHERE year ='2011' AND WHERE month ='05'

Filename: C:\wamp\www\mezobereny\system\database\DB_driver.php

Line Number: 330


Messages In This Thread
[SOLVED] query with variables - by El Forum - 06-11-2011, 06:24 AM
[SOLVED] query with variables - by El Forum - 06-11-2011, 06:48 AM
[SOLVED] query with variables - by El Forum - 06-11-2011, 07:00 AM
[SOLVED] query with variables - by El Forum - 06-11-2011, 07:43 AM
[SOLVED] query with variables - by El Forum - 06-11-2011, 08:22 AM
[SOLVED] query with variables - by El Forum - 06-11-2011, 08:35 AM
[SOLVED] query with variables - by El Forum - 06-11-2011, 08:43 AM
[SOLVED] query with variables - by El Forum - 06-11-2011, 08:44 AM
[SOLVED] query with variables - by El Forum - 06-11-2011, 08:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB