curl image into mysql.

hi, i got a problem insert a image that downloaded into mysql database,
because when i echo $sqlCmd, it output $data in binary file, please help
thanks

<?php
require ('dbconf.inc.php');
$table="myTable";
makeConnection($dbHost, $dbUser, $dbPasswd);

$url = 'http://www.google.com/intl/en_ALL/images/logo.gif';
$curl_handler = curl_init();
curl_setopt($curl_handler, CURLOPT_URL, $url);
curl_setopt($curl_handler, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handler, CURLOPT_BINARYTRANSFER, 1); //return the transfer
in a binary format .
$data = curl_exec($curl_handler);
curl_close($curl_handler);


$sqlCmd ="INSERT INTO $table(pid,city,cat,title,info,img1)
values('10','mycity','apa','me','yo',$data)";
mysql_query("$sqlCmd", $link) or die(mysql_errno() . ": " . mysql_error() .
"
");

?>



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Richard Lee [ So, 23 März 2008 04:08 ] [ ID #1930274 ]

Re: curl image into mysql.

richard lee wrote:
> hi, i got a problem insert a image that downloaded into mysql database,
> because when i echo $sqlCmd, it output $data in binary file, please help
> thanks

http://www.phpbuilder.com/columns/florian19991014.php3

--
Postgresql & php tutorials
http://www.designmagick.com/

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
dmagick [ Di, 25 März 2008 05:10 ] [ ID #1930570 ]
PHP » gmane.comp.php.database » curl image into mysql.

Vorheriges Thema: display fetched data in excel format
Nächstes Thema: Prevent global usage of last MySQL-Connection?!