-1

I have this structure on my code

   $query=mysql_query("SELECT * FROM kontratat WHERE 
uid=".$userRow['user_id'] WHERE data BETWEEN '".$fillo."' AND '".$mbaro."');

I got this error

"Parse error: syntax error, unexpected 'WHERE' (T_STRING) in /*.php on line 50"

I know that this is wrong because I was working on this and this works if I remove the "WHERE uid=".$userRow['user_id']"

But I need to get between two dates from ONE USERID ex

ex i have this table on db:

ID - UID - DATE - NAME - COUNTRY

1 - 2 - 2016-03-11 - ALesio - Belgium

2 - 2 - 2016-03-17 - Alex - Germany

3 - 3 - 2016-03-12 - George - England

Im Logged in as UID 2 but i need to view only lines by me not from userid 3 and between dates

something like this: SELECT * FROM table where uid=3 and date between 'mm/dd/yyyy' and 'mm/dd/yyyy'

I tested this and it didn't work.

Searched a lot on Google but nothing till now.

Can anyone help me?

Bimi Gjika
  • 25
  • 9

2 Answers2

0

Check this it will work

 $query=mysql_query("SELECT * FROM kontratat WHERE uid=".$userRow['user_id']." WHERE data BETWEEN '".$fillo."' AND '".$mbaro."');
Santosh Ram Kunjir
  • 1,068
  • 1
  • 12
  • 23
0

You need to store your dates to Y-m-d format.

I'm assuming your database table field is og type "date" i.e in Y-m-d format.

Try this:

$str = '24/12/2013';
$fillo_new = DateTime::createFromFormat('d/m/Y', $fillo);
$fillo_new = $date->format('Y-m-d');

$mbaro_new = DateTime::createFromFormat('d/m/Y', $mbaro);
$mbaro_new = $date->format('Y-m-d');

$query = "SELECT * FROM table where uid=3 and date between '".$fillo_new ."' and '".$mbaro_new ."' ";

Hope this helps.

Peace! xD

Object Manipulator
  • 8,485
  • 2
  • 9
  • 25