This topic is locked
[SOLVED]

 display image from database in a webpage

2/10/2012 4:23:04 AM
PHPRunner General questions
S
Sergej author

Hi, all

i'm trying to pull out the image from mysql database and to display it properly onto html webpage by inserting php snippet...text data is pulling out correctly also all $_Session variables are also correctly taken from database but withimage file it is another story - i get only an array of characters - many of them but no picture...
my php snippet looks like this

<?php $sql = ("SELECT maps FROM CountryList WHERE CountryName='Italy'");
$rs = CustomQuery($sql);
$data = db_fetch_array($rs);
echo $data["maps"];

?>

Table CountryList is with 3 fields, ID, CountryName and maps
Can you help me?

Thnx

J
Jane 2/10/2012

Hi,
the easiest way is to add CountryList table to your project, set up binary field (maps) as Imageon the 'View as' settings dialog.

Then use following code in your custom event:

$sql = ("SELECT maps FROM CountryList WHERE CountryName='Italy'");
$rs = CustomQuery($sql);
$data = db_fetch_array($rs);
echo "<img src=\"src="imager.php?table=CountryList&field=maps&key1=".$data["KeyField"]."\">";



where KeyField is your actual field name.
Then you can remove CountryList from menu or from project.

S
Sergej author 2/13/2012



Hi,
the easiest way is to add CountryList table to your project, set up binary field (maps) as Imageon the 'View as' settings dialog.

Then use following code in your custom event:

$sql = ("SELECT maps FROM CountryList WHERE CountryName='Italy'");
$rs = CustomQuery($sql);
$data = db_fetch_array($rs);
echo "<img src=\"src="imager.php?table=CountryList&field=maps&key1=".$data["KeyField"]."\">";



where KeyField is your actual field name.
Then you can remove CountryList from menu or from project.


Hi Jane,

Thnx for code but i seem to be getting the following error

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/ibrhr/public_html/upload/TCIMAIN/uk.php on line 116

when implementing your code

echo "<img src=\"src="imager.php?table=CountryList&field=maps&key1=".$data["ID"]."\">";

I was unable to locate the error source...can anyone help?

C
cgphp 2/13/2012
$sql = "SELECT maps FROM CountryList WHERE CountryName='Italy'";
$rs = CustomQuery($sql);
$data = db_fetch_array($rs);
echo "<img src=\"imager.php?table=CountryList&field=maps&key1=".$data["KeyField"]."\">";
S
Sergej author 2/13/2012

Thank you all!!!!