473,327 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

how to display an image with alphanumeric id

i have create a table with alphanumeri id number
but when i want to retreive my image i got this error

kindly help

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  include "file_constants.php";
  3.  // just so we know it is broken
  4.  error_reporting(E_ALL);
  5.  // some basic sanity checks
  6.  
  7.  
  8.  if(isset($_GET['id']) && is_numeric($_GET['id'])) {
  9.      //connect to the db
  10.      $link = mysql_connect("$host", "$user", "$pass")
  11.      or die("Could not connect: " . mysql_error());
  12.  
  13.      // select our database
  14.      mysql_select_db("$db") or die(mysql_error());
  15.  
  16.      // get the image from the db
  17.      $sql = "SELECT image FROM visa WHERE id=" .$_GET['id'] . ";";
  18.  
  19.      // the result of the query
  20.      $result = mysql_query("$sql") or die("Invalid query: " . mysql_error());
  21.  
  22.      // set the header for the image
  23.      header("Content-type: image/jpeg");
  24.      echo mysql_result($result, 0);
  25.  
  26.      // close the db link
  27.      mysql_close($link);
  28.  }
  29.  else {
  30.      echo 'Please use a real id number';
  31.  }
  32. ?>
Apr 4 '15 #1
2 1579
Luuk
1,047 Expert 1GB
What error did you get?
Apr 5 '15 #2
Dormilich
8,658 Expert Mod 8TB
a non-integer value must be quoted in SQL.

but that’s your least problem, because you’re highly vulnerable to SQL Injection.
Apr 7 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Philipp Lenssen | last post by:
I created Search.CSS which grabs Google results (using the Web API), displays as XHTML1.0 Strict + CSS, and recently also adds Thumbnails....
0
by: Qindong Zhang | last post by:
My asp.net application send image to web browser. The browser begin to display image before download finished. (In Slow Network). How can I force brower to display image after the image downloaded? ...
1
by: Tan | last post by:
Hi I am desperate for any help with display image in Gridview I have a gridview contain surname , forename ..... and image. I could not display image as my database store the column image as...
2
by: David | last post by:
I am trying to get an image to appear on all Mondays within the calendar control. I also want that image to be a link. How can I do this?
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
3
by: Ladislav Andel | last post by:
Hi, I'm trying to display image through my cgi script in HTML page via <img src="image.cgi"> Can you give me an example, please? What should be in the cgi script to display it? Here is what...
7
by: alexseow | last post by:
Query.asp <%@ LANGUAGE="VBSCRIPT" %> <!-- #include file="../../includes/dbconn.asp"--> <% dim MyRs, sqlstr, MyConn Response.Expires = 0 Response.Buffer = TRUE Response.Clear
0
by: dbdb | last post by:
hi, i work with ms. access 2003 i want to display image from a folder to the report. i have read thread in http://bytes.com/topic/access/answers/191611-pictures-access-reports but that's...
1
by: zak200 | last post by:
Hi, I am trying to display image , but its not working. #!C:/Perl64/bin/perl.exe print "Content-type: image/gif\n\n"; print <<EOF; <HTML> <HEAD> <TITLE> Coding Page </TITLE> </Head>
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.