473,394 Members | 1,875 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,394 software developers and data experts.

problem with display images

118 100+
Hi,

I write the code to display images.But it will not display image.And also gives the error like that

error : Notice: Undefined index: gim in F:\Facebook\pic_up.php on line 59

plz tell that what is the problem in that code

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. // Connect to database
  4.  
  5. $errmsg = "";
  6. if (! @mysql_connect("localhost","root","root")) {
  7.         $errmsg = "Cannot connect to database";
  8.         }
  9. @mysql_select_db("rainlist");
  10.  
  11. // First run ONLY - need to create table by uncommenting this
  12. // Or with silent @ we can let it fail every sunsequent time ;-)
  13.  
  14. $q = <<<CREATE
  15. create table pix (
  16.     pid int primary key not null auto_increment,
  17.     title text,
  18.     imgdata blob)
  19. CREATE;
  20. @mysql_query($q);
  21.  
  22. // Insert any new image into database
  23.  
  24. if ($_REQUEST['completed'] == 1) {
  25.         // Need to add - check for large upload. Otherwise the code
  26.         // will just duplicate old file ;-)
  27.         // ALSO - note that latest.img must be public write and in a
  28.         // live appliaction should be in another (safe!) directory.
  29.         move_uploaded_file($_FILES['imagefile']['tmp_name'],"latest.img");
  30.         $instr = fopen("latest.img","rb");
  31.         $image = addslashes(fread($instr,filesize("latest.img")));
  32.         if (strlen($instr) < 149000) {
  33.                 mysql_query ("insert into pix (title, imgdata) values (\"".
  34.                 $_REQUEST['whatsit'].
  35.                 "\", \"".
  36.                 $image.
  37.                 "\")");
  38.         } else {
  39.                 $errmsg = "Too large!";
  40.         }
  41. }
  42.  
  43. // Find out about latest image
  44.  
  45. $gotten = @mysql_query("select * from pix order by pid desc limit 1");
  46. if ($row = @mysql_fetch_assoc($gotten)) {
  47.         $title = htmlspecialchars($row['title']);
  48.         $bytes = $row['imgdata'];
  49. } else {
  50.         $errmsg = "There is no image in the database yet";
  51.         $title = "no database image available";
  52.         // Put up a picture of our training centre
  53.         $instr = fopen("latest.img","rb");
  54.         $bytes = fread($instr,filesize("latest.img"));
  55. }
  56.  
  57. // If this is the image request, send out the image
  58.  
  59. if ($_REQUEST['gim'] == 1) {
  60.         header("Content-type: image/jpeg");
  61.         print $bytes;
  62.         exit ();
  63.         }
  64. ?>
  65.  
  66. <html><head>
  67. <title>Upload an image to a database</title>
  68. <body bgcolor=white><h2>Here's the latest picture</h2>
  69. <font color=red><?= $errmsg ?></font>
  70. <center><img src=?gim=1 width=144><br>
  71. <b><?= $title ?></center>
  72. <hr>
  73. <h2>Please upload a new picture and title</h2>
  74. <form enctype=multipart/form-data method=post>
  75. <input type=hidden name=MAX_FILE_SIZE value=150000>
  76. <input type=hidden name=completed value=1>
  77. Please choose an image to upload: <input type=file name=imagefile><br>
  78. Please enter the title of that picture: <input name=whatsit><br>
  79. then: <input type=submit></form><br>
  80. <hr>
  81. By Graham Ellis - <email removed>
  82. </body>
  83. </html>
  84.  
Jun 7 '08 #1
1 2027
Markus
6,050 Expert 4TB
The array index 'gim' doesn't exist.

Make sure you have it set to the right name.

Also, use code tags!
Jun 7 '08 #2

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

Similar topics

10
by: Mark McLellan | last post by:
Dear all Following the oft-repeated advice here and ciwas I have made my site nearly 4.01 strict (working on it). There are some items on which I would appreciate your advice: 1. Hidden...
8
by: nick | last post by:
I have a problem and I've been using a cheezy work around and was wondering if anyone else out there has a better solution. The problem: Let's say I have a web application appA. Locally, I set...
1
by: books1999 | last post by:
Hi there, I have a problem with this css/div and i cannot work it out. I would like either container to be able to push the background box to grow but in Firefox it overflows. Can someone find a...
8
by: DJA | last post by:
Hello, I site I designed has links that don't seem to work in mac IE 5.2. In my site I'm using CSS to imitate image buttons by using the background image property along with a little extra...
3
by: autospanker | last post by:
Ladies and Gentleman, I have been having this problem that has been driving me insane. I have a website that when viewed in Firefox first, the content in the body area is pushed down. Then when...
0
by: sjickells | last post by:
Hi I am having a problem using asp:TextBox's in a transparent table. I have a background image on the page and a table in the middle of the page. I have set the background colour of the table...
1
by: rirby2 | last post by:
Hi everyone, I'm currently having a rendering problem in IE7 (haven't even tried the lower IEs yet), vs. what I see in FF2. The simplified site can be found at solerasd.com . (There are more...
2
by: stevemtno | last post by:
I've got a problem with a web page I'm working on. I have 4 modules - one of them has 2 tabs, two of them have 4 tabs. When the user clicks on the tabs, the content below them changes. However, when...
3
by: Steve | last post by:
Hi All I have an asp.net 2.0 website with the following css file It uses Master pages and in Firefox 3.04 for windows only, 3 of the web pages don't display the Master page properly The...
2
by: swethak | last post by:
Hi, I am getting the problem the problem with google map in Internet Explorer. This map worked fine in mozilla . When i opened the same map in Internet Explorer i am getting the error...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.