Executing SQL using PDO causes the connection to be reset.

Source: Internet
Author: User
Tags sql using
When you run the SQL statement using PDO, the connection is reset. it is okay to connect to the database using PDO:
$dsn = "mysql:host=localhost;dbname=php_jquery_example";try {$dbo = new PDO($dsn, 'root', '123');} catch(Exception $e) {die($e->getMessage());}


No problem with preprocessing and binding:
$sth = $dbo->prepare('SELECT event_id, event_title, event_desc    FROM events    WHERE event_id < ?');$sth->bindParam(1, $calories, PDO::PARAM_INT);


The problem is:
$sth->execute();

The page directly dies, prompting the connection to be reset
The same problem occurs during direct execution:
foreach ($dbo->query('select * from events') as $row) { ...



It is okay to connect and query using the original method. this is caused by the execution of SQL statements by PDO and has been entangled for two days. please help me .....


Reply to discussion (solution)

The following information is printed in the aparch error log:
[Error] VirtualHost *: 80 -- mixing * ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined results
PHP Warning: PHP Startup: Unable to load dynamic library '.. \\.. \ php-5.2.14-Win32 \ ext \ php_mssql.dll '-\ xd5 \ xd2 \ xb2 \ xbb \ xb5 \ xbd \ xd6 \ xb8 \ xb6 \ xa8 \ xb5 \ xc4 \ xc4 \ xa3 \ xbf \ xe9 \ xa1 \ xa3 \ r \ n in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '.. \\.. \ php-5.2.14-Win32 \ ext \ php_pdo_mssql.dll '-\ xd5 \ xd2 \ xb2 \ xbb \ xb5 \ xbd \ xd6 \ xb8 \ xb6 \ xa8 \ xb5 \ xc4 \ xc4 \ xa3 \ xbf \ xe9 \ xa1 \ xa3 \ r \ n in Unknown on line 0

Help analysis.

The advantage of using pdo is ?????

PHP Warning: PHP Startup: Unable to load dynamic library'
Cannot load dynamic library: php_mssql.dll php_pdo_mssql.dll

Is the lack of these two databases affects page execution.

PHP Warning: PHP Startup: Unable to load dynamic library'
Cannot load dynamic library: php_mssql.dll php_pdo_mssql.dll

Is the lack of these two databases affects page execution.

Not to mention SQL Server.

The advantage of using pdo is ?????

For general purpose, you only need to replace the DSN string for changing the database system.
Of course, differences must be taken into account in SQL commands.

Is the problem solved?

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.