Re: PDO/MYSQL Problem



macca wrote:
Hi, I'm trying to store a pdf in mysql, any ideas why this isnt
working? If i exchange $file for 'test', that works. Bit confused. Any
ideas?

<?php

try {
$pdo = new
PDO('mysql:host=localhost;dbname=pdf','root','password');
} catch(PDOException $e) {
echo "An error occured when connecting: ".$e->getMessage();
}


// insert a pdf into the database
$file = file_get_contents('document.pdf');


$pdo->exec("INSERT INTO file(filename) VALUES('$file')");

?>


It should be:

$pdo->exec("INSERT INTO table(column) VALUES('$file')");

But I think that's what you mean (at least I hope so).

How big is your PDF? How big is your column? What is the result of the $pdo->exec() call? If it's false, what's the error?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================

.



Relevant Pages

  • Re: [PHP] Does PDO prevent class functions from calling other class functions?
    ... I just took a quick look at the try/catch ... >exceptions which isn't particularly useful if it's PHP itself that is ... well, youre not throwing an exception here in your code, your doing something called ... Here's the MySQLDatabase "query_database' function that passes the actual call to PDO ...
    (php.general)
  • Re: [PHP] moving over to php 5
    ... When the developer benefits from something being "more standard" and ... more secure, then he'll change. ... your hands in the air and hoping PHP, PDO, magic_quotes, etc, etc will ...
    (php.general)
  • Re: Any PHP / Exchange experts here (about mail relaying) ?
    ... to relay mails from PHP to the Exchange box. ... >> And this to emulate GetMXRR PHP function that does not work under ...
    (comp.lang.php)
  • Re: PHP 5.2.1+ Informix is no longer bundled with PHP
    ... just found the PDO stuff on IBM's site. ... backward compatible with our current PHP apps calling Informix? ... The old IFX module, just like all other DB access modules in PHP before ... Improved Performance) is worth the price of admission. ...
    (comp.databases.informix)
  • Storing and passing secure passwords to MS Exchange
    ... email/calendar information from Microsoft Exchange. ... integrate PHP with Exchange via WebDAV. ... I need to encrypt the passwords for database storage. ...
    (comp.lang.php)