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

code for retrieving image in database.

Paul NIcolai Sunga
is this applicable?


Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3. $query = mysqli_query($Link, "SELECT * from Registration_form where last_insert_id(form_no)" );
  4.  while($row = mysqli_fetch_array($query)){
  5. $picture = $row['picture'];
  6. }
  7. ?>
  8.  

thanks...:)
Jul 29 '09 #1
10 3444
Dormilich
8,658 Expert Mod 8TB
what does the manual say?
Jul 29 '09 #2
Canabeez
126 100+
Nope...

You have a few mistakes in your code, (first) the $Link variable should go as a second parameter; (second) last_insert_id() cannot be used in SELECT, only in INSERT; (third) there's no point in while if you want a single row.

Here, if your form_no is auto_increment then this code should work:
Expand|Select|Wrap|Line Numbers
  1. $query = mysql_query("SELECT `picture` FROM `Registration_form` ORDER BY `form_no` DESC LIMIT 1;", $Link);
  2.  
  3. if($row = mysql_fetch_row($query))
  4. {
  5.    $picture = $row['picture'];
  6. }
Jul 29 '09 #3
Dormilich
8,658 Expert Mod 8TB
@Canabeez
sorry to correct you here, mysqli_* indeed uses the connection instance as first parameter (in contrast to mysql_*)

although if I’d be using MySQLi I’d rather use the object oriented style.
Jul 29 '09 #4
Canabeez
126 100+
@Dormilich
Thanks... you're right... didn't mention the mysqli, didn't even think that anyone really uses that... I think the rest is fine...
Jul 29 '09 #5
Dormilich
8,658 Expert Mod 8TB
@Canabeez
although I find MySQLi much more capable than mysql_*. guess most people are already accustomed to mysql_* and don’t want to change for the better…
Jul 29 '09 #6
Canabeez
126 100+
not only accustomed, think of all the code, rewrite all that?! hell no... only I have something like 50,000 lines using mysql_.
Jul 29 '09 #7
thanks for correcting my errors in my codes..thanks a lot.. it is a big help for me..
Jul 29 '09 #8
whats this warning?


Warning: mysql_query() expects parameter 2 to be resource, object given in C:\wamp\www\dfdfdd.php on line 16

Warning: mysql_fetch_row() expects parameter 1 to be resource, null given in C:\wamp\www\dfdfdd.php on line 18
Jul 29 '09 #9
Expand|Select|Wrap|Line Numbers
  1. <?Php   
  2. error_reporting (E_ALL ^ E_NOTICE);
  3.  
  4. $Link = mysqli_connect("localhost","root","tupi", "amyak_maleh");
  5.             if (!$Link)
  6.               {
  7.               trigger_error("Could not connect", E_USER_ERROR );
  8.               }
  9. $query = mysqli_query($Link, "SELECT picture FROM Registration_form ORDER BY form_no DESC LIMIT 1" );
  10.  
  11.    if($row = mysqli_fetch_row($query))
  12.    {
  13.      $picture1 = $row['picture'];
  14.    }
  15.  
  16.    ?>
  17.  
  18. <table width="200" border="1">
  19.   <tr>
  20. <td><input name="pix" type="image" value="<?Php  error_reporting (E_ALL ^ E_NOTICE);  echo $picture; ?>"/></td>
  21. </tr>
  22. </table>
  23.  

is this correct? the picture is not appearing..
Jul 29 '09 #10
Dormilich
8,658 Expert Mod 8TB
@Paul NIcolai Sunga
of course. the image is referenced using the "src" attribute (which btw is a file name). It's completely useless to try inserting the image data (binary type) into html sorce code (text type).

see also Atli's article
Jul 29 '09 #11

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

Similar topics

0
by: JPRW | last post by:
Hello All. I am having issues with the visualbasic gramatic for the following scenario: I am retrieving information from an Access 2000 Database. The current fields are: ebay, which is a...
0
by: Sreesekhar Palaparthy | last post by:
I used mysql_real_escape_string() method to insert image file into database. Now how do icheck whether it got stored in proper format ?? I used SELECT * INTO OUTFILE F1 FROM IMGTABLE; ...
1
by: JPRW | last post by:
Hello All. I am having issues with the visualbasic gramatic for the following scenario: I am retrieving information from an Access 2000 Database. The current fields are: ebay, which is a...
0
by: alienize | last post by:
Does anyone know how i would retrieve stored images from my access database(I've stored them as OLE objects) and then bind the retrieved image to an Image Control? Also, How would i retrieve an...
1
by: Adam | last post by:
I am having difficulty retrieving images from a SQL database. Here is the code I use to UPLOAD the image to the database: <form id="Form1" method="post" enctype="multipart/form-data"...
6
by: Dean Slindee | last post by:
Does anybody have an actual example of retrieving an Image data type column from a SQL Server table using a dataset (not a datareader)? I would like to see the statements that would move the...
0
by: kid4rilla | last post by:
I can successfully write the binary data to an image data type, and successfully retrieve it, but when I attempt to play the file in media player after retrieving it, I get the file type isn't...
0
by: islay | last post by:
I'm trying to retrieve an image from an Access 97 database and printing it on a report. I'm using a 'System.Data.OleDb.OleDbConnection()' object to connect to the database, a...
7
by: Sirplaya | last post by:
I am retrieving images that I stored in SQL Server on my web pages in C#. I have no problem with the images displaying, however, I am trying to wrap the image with an <A HREF ..." and each time I...
3
by: zafar | last post by:
hi, I am facing problem while adding picture in database and retrieving it again on a form. can any body help me in this regard, I need code that would be able to solve my problem... thanx.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.