php mysql比较相等的日期

I am using php to access fields from 2 tables.

This part works just fine

   $sql=mysql_query('SELECT * FROM user_weeks WHERE user_id = '.$_SESSION["user_id"].' ORDER BY date DESC') or die(mysql_error());

I get the date just fine by doing this

    $infodate=$info["date"];
    echo $infodate;

However I'm trying to take that date and compare it to one in a different table as such

$sql2=mysql_query('SELECT * FROM weekly_ROI WHERE date = '.$infodate.' ') or die(mysql_error());

however, that gives me no results. I'm a noob so sorry if this code is so "2000 and late"

Presumably you're using a standard yyyy-mm-dd type date string in your query, which means you're lacking quotes around the date value:

$sql2=mysql_query('SELECT * FROM weekly_ROI WHERE date = '.$infodate.' ')
                                                         ^--here          ^-- here

Your query will look like

... WHERE date = 2013-12-18

and be evaluated as a simple mathematical subtraction:

... WHERE date = 1983

You need quotes:

.... date = "' . $infodate . '"');
            ^--               ^--

Assuming both date fields are of type date, you need to wrap the name date in backticks, since date is a reserved word and you need to wrap your date in quotes.

$sql2=mysql_query('SELECT * FROM weekly_ROI WHERE `date` = "'.$infodate. '"') or die(mysql_error());

Also, mysql_* functions are deprecated. You need to look into using PDO or mysqli to query your database.

date is reserved word use to wrap inside the backtick `date

$sql2=mysql_query('SELECT * FROM weekly_ROI WHERE `date` = "'.$infodate.'" ') or die(mysql_error());