PHP returns invalid MySQL resource

    $LDATE = '#' . $_REQUEST['LDateDay'] . '/' . $_REQUEST['LDateMonth'] . '/' . $_REQUEST['LDateYear'] . '#';
    $RDATE = '#' . $_REQUEST['RDateDay'] . '/' . $_REQUEST['RDateMonth'] . '/' . $_REQUEST['RDateYear'] . '#';
    include("../../sql.php");
    $myconn2 = mysql_connect(/*removed*/, $username, $password);
    mysql_select_db(/*removed*/, $myconn2);
    $LSQLRequest = "SELECT * FROM flight WHERE DepartureDate = ".$LDATE;
    $LFlights = mysql_query($LSQLRequest, $myconn2);
    $RSQLRequest = "SELECT * FROM flight WHERE DepartureDate = ".$RDATE;
    $RFlights = mysql_query($RSQLRequest, $myconn2);

Assuming all $ _REQUESTs are valid numerical values ​​for their respective fields in the day / month / year field, how can LFlights and RFlights be invalid? When I polled the entire database, I got hundreds of results, so I know that the database and connection data is beautiful, and the DepartureDate field also exists.

Edit: When I pulled out the entire contents of the database, the dates returned in the "YYYY-MM-DD" format. So I converted D to a string if it was <10 and then 0D. Then built the line YYYY-MM-DD. Still no results. Now there are no errors, but no results. I selected the values ​​that I knew had entries in them.

+3
2

MySQL YYYY-MM-DD . DD-MM-YYYY MySQL.

. http://dev.mysql.com/doc/refman/5.1/en/datetime.html

, , , .


, , , :

SELECT * FROM flight WHERE DepartureDate = 2010/5/3.

2010, 5, 3, 134,0. .

SELECT CURDATE() = 2010/5/3;

false.

SELECT CURDATE() = '2010/5/3';

true;

+1

Ldate Rdate qoutes.

$LSQLRequest = "SELECT * FROM flight WHERE DepartureDate = '".$LDATE."'";
$RSQLRequest = "SELECT * FROM flight WHERE DepartureDate = '".$RDATE."'";

, #. Access.

 $LDATE = $_REQUEST['LDateDay'] . '/' . $_REQUEST['LDateMonth'] . '/' . $_REQUEST['LDateYear'] ;
 $RDATE = $_REQUEST['RDateDay'] . '/' . $_REQUEST['RDateMonth'] . '/' . $_REQUEST['RDateYear'] ;
+1

Source: https://habr.com/ru/post/1743874/


All Articles