Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is the a version of the code you posted, but using SQLite instead of MySQL:</p> <pre><code>&lt;?php header("Content-type: text/xml"); $dbhandle = sqlite_open('sqlitedb'); $query = sqlite_query($dbhandle, 'SELECT * FROM blog ORDER BY date DESC'); $result = sqlite_fetch_all($query, SQLITE_ASSOC); try { $db = new PDO("sqlite:/path/to/database.db"); } catch(PDOException $e) { die('Unable to connect to database: ' . $e-&gt;getMessage()); } $query = $db-&gt;prepare("SELECT * FROM blog ORDER BY date DESC"); $query-&gt;execute(); $result = $query-&gt;fetchAll(); $xml_output = "&lt;?xml version=\"1.0\"?&gt;\n"; $xml_output .= "&lt;entries&gt;\n"; foreach ($result as $row) { $xml_output .= "\t&lt;entry&gt;\n"; $xml_output .= "\t\t&lt;date&gt;" . $row['date'] . "&lt;/date&gt;\n"; // Escaping illegal characters $row['text'] = str_replace("&amp;", "&amp;", $row['text']); $row['text'] = str_replace("&lt;", "&lt;", $row['text']); $row['text'] = str_replace("&gt;", "&amp;gt;", $row['text']); $row['text'] = str_replace("\"", "&amp;quot;", $row['text']); $xml_output .= "\t\t&lt;text&gt;" . $row['text'] . "&lt;/text&gt;\n"; $xml_output .= "\t&lt;/entry&gt;\n"; } $xml_output .= "&lt;/entries&gt;"; $db = null; </code></pre> <p>Here is the <a href="http://us2.php.net/manual/en/book.pdo.php" rel="nofollow noreferrer">PHP documentation for PDO</a> for more information.</p> <p>Here is a <a href="http://www.phpro.org/tutorials/Introduction-to-PHP-PDO.html" rel="nofollow noreferrer">tutorial for using PDO</a>.</p> <p>EDIT: Changed code to use <code>PDO</code> instead of the <code>sqlite_*</code> functions.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload