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

Why I cant to retreive image from database via php?

This is my code. Could you correct? Thanks in advance
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo <<<_END
  3. <DOCTYPE html><html><head><meta charset="utf-8"></head>
  4. _END;
  5.  
  6. require_once'login.php';
  7. $connection=new mysqli($db_hostname, $db_username, $db_password, $db_database);
  8.  
  9. if($connection->connect_error) die($connection->connect_error);
  10.  
  11. if (
  12.     isset($_POST['title'])&&
  13.     isset($_POST['category'])&&
  14.     isset($_POST['name'])&&
  15.     isset($_POST['telno'])&&
  16.     isset($_POST['price'])&&
  17.     isset($_POST['info']))
  18. {
  19.     $title=get_post($connection, 'title');
  20.     $category=get_post($connection, 'category');
  21.     $name=get_post($connection,'name');
  22.     $telno=get_post($connection,'telno');
  23.     $price=get_post($connection,'price');
  24.     $info=get_post($connection,'info');
  25.  
  26.         if (is_uploaded_file($_FILES['img1']['tmp_name']))
  27.     {
  28.  
  29.                 $imgData=addslashes(file_get_contents($_FILES['img1']['tmp_name']));
  30.                     $query="INSERT INTO avto(title, category, img1,  name, telno, price, info) VALUES" . 
  31.                     "('$title', '$category', '$imgData',  '$name', '$telno', '$price', '$info')";
  32.  
  33.                 $result = $connection->query($query);
  34.  
  35.                 if(!$result)
  36.                     echo "Кушиб булмаяпти: $query<br>".
  37.                     $connect_error. "<br><br>";
  38.  
  39.     }
  40.  
  41.  
  42. }
  43.  
  44. echo <<<_END
  45.     <form action="index.php" method="post" enctype="multipart/form-data"><pre>
  46.     Title <input type="text" name="title">
  47.     Category <input type="text" name="category">
  48.     Main img <input type='file' name='img1' >
  49.  
  50.     Name <input type="text" name="name">
  51.     Tel NO <input type="text" name="telno">
  52.     Price <input type="text" name="price">
  53.     Info <textarea rows="6" cols="30" name="info"></textarea>
  54.     <input type="submit" value="Submit">
  55.     </pre></form>
  56. _END;
  57.  
  58.  
  59. $query="SELECT * FROM avto";
  60. $result=$connection->query($query);
  61.  
  62. If (!$result) die ($connection->error);
  63. $rows=$result->num_rows;
  64.  
  65. for ($j=0;$j<$rows;++$j)
  66. {
  67. $result->data_seek($j);
  68. $row=$result->fetch_array(MYSQLI_NUM);
  69.  
  70.     echo <<<_END
  71.         <pre>
  72.         $row[0]
  73.         $row[1]
  74.         $row[2]
  75.         $row[3]
  76.         $row[9]
  77.         $row[10]
  78.         $row[11]
  79.         $row[12]
  80.         $row[13]
  81.         </pre>
  82. _END;
  83. }
  84. $result->close();
  85. $connection->close();
  86. function get_post($connection, $var)
  87. {
  88.     return $connection->real_escape_string($_POST[$var]);
  89. }
  90. echo <<<_END
  91. </html>
  92. _END;
  93. ?>
Jun 25 '15 #1
1 1284
computerfox
276 100+
Where did you find this code? This doesn't look like valid PHP code.
Jun 25 '15 #2

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

Similar topics

3
by: AlexGreif.2609394 | last post by:
Hi, I looked at the PIL Image class but cannot see a posibility to retreive the image resolution dots per inch (or pixels per inch) Could somebody please tell me how to get these metadata infos...
1
by: Steven Caliendo | last post by:
Hi, Can someone give me an example of a query that will update a database with an Image type ? So, if I have a picture file on my web server, and I want to add it to my SQL database in a field...
0
by: Tim::.. | last post by:
Please, please, please help!!! I have a datagrid that displays a list of contacts on our intranet site using the ActiveDirectory as it's main Data Source. I want to be able to show an image of...
1
by: Jean Christophe Avard | last post by:
Hi! I have a dataset where I have a field that is a image. I can't figure out how to retreive the imahe, I get the invalid paranmeter with this code... Try Dim buffer() As Byte =...
1
by: miguelfc | last post by:
Hi, I've searched a lot and couldn't find an answer to my problem. I want to have a field in my form that allow me to paste an image from the clipboard to, for example, a Paint field. Then, I...
4
by: ghowells | last post by:
I've been trying to create an image database using Access 2000 linked to all the images on our server, as per the instructions on the microsoft website. The code to link the photos is as follows:...
2
by: oren18 | last post by:
hello.does anybody know .. how to make an image database by using VB.NET 2005 and Microsoft Access i want to make an application ( VB.NET 2005 ) that prompt a user to put his picture into...
0
by: oren18 | last post by:
hello.does anybody know .. how to make an image database by using VB.NET 2005 and Microsoft Access i want to make an application ( VB.NET 2005 ) that prompt a user to put his picture into...
6
n8kindt
by: n8kindt | last post by:
i have linked a mySQL database (that populates data in our webstore) with my Access 2007 database. i want to be able to see the images in access also. however, i only have a referring url to work...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.