Re: PDO/MYSQL Problem



macca wrote:
ok,

I changed the statement to this

$pdo->exec("INSERT INTO file(filename) VALUES('$file')") or
die(print_r($pdo->errorInfo()));

And go this error

Array ( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL
syntax; check the manual that corresponds to your MySQL server version
for the right syntax to use near 'â/îÚ{%9²°†3äìÛZûòæÝc¤6öîÏË»7Ëe¬"µ
\ß-Tˆ¿…JÒ<ÈTA‡‰Zîî V›»Y„a”ªeyG«$WËÃÝGoé' at line 1 ) 1

So then i added addslashes() to the file_get_contents() like so:

$file = addslashes(file_get_contents('document.pdf'));

and it worked fine.

Thanks Jerry



You shouldn't use addslashes(). Rather, you should be using mysql_real_escape_string(), or, better yet, bind variables in PDO.

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

.



Relevant Pages

  • Re: PDO/MYSQL Problem
    ... syntax; check the manual that corresponds to your MySQL server version ... So then i added addslashes() to the file_get_contentslike so: ...
    (comp.lang.php)
  • Re: Pulling data based on date time returns error
    ... check the manual that corresponds to your MySQL server version for the ... right syntax to use near '"Select Result from DataListing where ... I would guess that you have an error in your SQL syntax; ...
    (comp.lang.perl.misc)
  • Re: MySQL has gone away
    ... though I don't know how to interprete these ... the manual that corresponds to your MySQL server version for the right ... syntax to use near '‘SET NAMES utf8′' at line 1 ...
    (Fedora)
  • Re: using COUNT with CGI
    ... You have an error in your SQL syntax. ... that you should check the manual that corresponds to your MySQL server ... what do you think COUNTin SQL does? ...
    (perl.beginners)
  • Re: Php MySQL query wont work..syntax error..help!
    ... You have an error in your SQL syntax; ... corresponds to your MySQL server version for the right syntax to use ...
    (comp.lang.php)