0

hello,..

i have problem with my script, my goals to display image from my query result.
i created picture database contain id, name & link (data contain link to picture folder localhost/nseries/A2-1C1-1B.png)

on my query display i created dynamic link to picture but when i click the link nothing show up

i've tried different script but nothing comes out only blank screen

php script i've tried

<?php
$q=$_GET["id"];

$con = mysql_connect('localhost', 'sigit_p', 'h4ngg401');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("kdplnseries", $con);

$query = "SELECT link FROM asmmanual WHERE id = '".$q."'";

$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
echo "<img src=\"". $row['link'] ."\" alt=\"\" />";
?>

also

<?php
$q=$_GET["id"];

$con = mysql_connect('localhost', 'sigit_p', 'h4ngg401');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("kdplnseries", $con);

$data = mysql_query("SELECT * FROM asmmanual WHERE id = '".$q."'");

while($result = mysql_fetch_array( $data ))
  {
  echo '<img src="'.$q.'" width="312" height="50" alt="'.$q.'"(83 bytes)" />';
  }  

mysql_close($con);
?> 

please help solve my problem ,...

thanks

5
Contributors
11
Replies
14
Views
5 Years
Discussion Span
Last Post by sigit_p
0

goto the view source of your browser and check wheather the image path is correct or not in source.

Edited by karthik_ppts

0

page source came out empty ,..nothing,.blank,..no script

0

Check what is the path coming from your database.

Try like this and paste your output on the screen

echo $row['link']; exit;
echo "<img src='". $row['link'] ."' alt='' />";
0

do you mean like this

<?php
$q=$_GET["id"];

$con = mysql_connect('localhost', 'sigit_p', 'h4ngg401');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("kdplnseries", $con);

$query = "SELECT link FROM asmmanual WHERE id = '".$q."'";

$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
echo $row['link']; exit;
echo "<img src='". $row['link'] ."' alt='' />";

?> 

result still blank,..

0

Try this code:

echo $query = "SELECT link FROM asmmanual WHERE id = '".$q."'"; exit;

You will see one quesy in browser, copy that query and run it in your mysql query window.
Post what is your query output.

0

if i insert you code

<?php
$q=$_GET["id"];

$con = mysql_connect('localhost', 'sigit_p', 'h4ngg401');
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("kdplnseries", $con);

echo $query = "SELECT link FROM asmmanual WHERE id = '".$q."'"; exit;

$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_array($result) or die(mysql_error());
echo $row['link']; exit;
echo "<img src='". $row['link'] ."' alt='' />";

?> 

my query output will be

SELECT link FROM asmmanual WHERE id = 'A2-1C1-1B'

is it right or wrong ???,... sorry i'm still new in php

thanks

0
$q=$_GET['id'];
$con = mysql_connect('localhost', 'sigit_p', 'h4ngg401');
 if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
 mysql_select_db("kdplnseries", $con);

//end of your conn.
 $query = mysql_query("SELECT link FROM asmmanual WHERE id = '$q' LIMIT 1") or die(mysql_error());
while($imglink = mysql_fetch_assoc($query){
 echo '<a href="'.$imglink['link'].'" target="_blank"><img src="'.$imglink['link'].'" alt="" /></a>';
}
 ?>

I think something like that should help you out, if you still don't get the right img , go and check exact path of the image if part is broken or need to be edit to be the correct one .

Regards
Rimo

0

result still empty page,..blank,..

can you give me example for displaying image from database which contain link to image,.. ????

previously i found tutorial for displaying image but database type using BLOB, in some people opinion BLOB is not recomended for storing large image file.

thank you

0

after i recheck database and edit some error from Rimotevst the problem solved,
thanks to you all and specially for Rimotevst
and the code goes like this

<?php
$q=$_GET['id'];
$con = mysql_connect('localhost', 'sigit_p', 'h4ngg401');
 if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }
 mysql_select_db("kdplnseries", $con);
    //end of your conn.
$query = mysql_query("SELECT link FROM asmmanual WHERE id = '$q' LIMIT 1") or die(mysql_error());
while($imglink = mysql_fetch_assoc($query))
 {
 echo '<a href="'.$imglink['link'].'" target="_blank"><img src="'.$imglink['link'].'" alt="" /></a>';
 }
?>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.