PHP PDO connection MySQL data query data

Source: Internet
Author: User

HTML code

The code is as follows Copy Code
<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>ansys Tutorials </title>
<body>

</body>

PHP code

The code is as follows Copy Code

$db = new Sqlite3 (' MySQL tutorial itedb.db ');

Get file 2 feed stream
$filename = "/www.111cn.net/logo.gif";
$handle = fopen ($filename, "R");
$contents = Fread ($handle, FileSize ($filename));
Fclose ($handle);
Creating data Tables
$db->exec (' CREATE TABLE person (idnum text,name text,photo blob) ');

$stmt = $db->prepare ("INSERT into person values (' 41042119720101001x ', ' John ',?)");
$stmt->bindvalue (1, $contents, Sqlite3_blob);
$stmt->execute ();

<?php

The code is as follows Copy Code
$pdo = new Sqlite3 (' mysqlitedb.db ');
$results = $pdo->query (' select * from person ');
while ($row = $results->fetcharray ()) {
Ob_start ();
Header ("content-type:image/jpg");
echo $row [' photo '];
Ob_end_flush ();
}

?>

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.