PHP gets issues with Sybase database content
The database connection has been tested, and the SQL statement is no problem. Now the problem is not getting the data in the database, the code is as follows:
public static function Connect ()
{
$obj =new DB ();
$conn = $obj->connection=sybase_connect (server_name, USER, PASSWORD); Connecting to a database
if (! $conn) {
Echo ' Database connection error ... ';
Exit (0);
}
SYBASE_SELECT_DB (database_name);
return $obj;
}
Query the last one months for sales records when initializing a page
Public Function Querylastmonth () {
$start _date=str_replace ('-', ' ', Date (' y-m-d ', Strtotime ('-1 month '));
$end _date=str_replace ('-', ' ', Date (' y-m-d ', Time ()));
$sql _str= "Select Cusno as Shopcode,u2.nos as salesid,u2.colthno as goodsid,u2.endprice as price,u2.nb as Goodscount from u 2sale U1,u2saleb U2 where u1.outdate>= ";
$sql = $sql _str. "". $start _date. "' and u1.outdate<= '". $end _date. "' and U1.nos=u2.nos and u1.nb>0 and u2.endprice>0; ';
Echo $sql;
Sybase_query ("SET ROWCOUNT"). 20); Execute SQL command, set the number of returned record rows
$result = Sybase_query ($sql); Execute SQL command to retrieve database
echo "---". $result;
while ($row = Sybase_fetch_assoc ($result))
{
echo ' xxx ';
echo $row ["Shopcode"]. "---" . $row ["Salesid"]. "---" . $row ["Goodscount"]. "\ n";
}
Sybase_close ($conn);
}
Please advise
Share to: more
------Solution--------------------
Just take the printed SQL and put it in the editor to do it.
------Solution--------------------
So Echo $result; What did you get?
Echo Sybase_get_last_message (); And what did you see?