PHP access to Sybase database content issues

Source: Internet
Author: User
Tags sybase sybase database
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?
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.