473,326 Members | 2,010 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,326 software developers and data experts.

problem when updating image: field is empty in database

hello all friend...here i'm have some problem with my code...i can't update my image...
here my full code

index.php

Expand|Select|Wrap|Line Numbers
  1.     //this link will post my data to next page
  2.     <a href="updatepage.php?code=<?php echo $row['name']; ?>">update</a> 
  3.  
  4. updatepage.php
  5.  
  6.      //this page will get all data that want to update...
  7.      <?php
  8.      include("config.php");
  9.      $name=$_GET['code'];
  10.             $sql1  = "select * from imagename where name='$name'";
  11.             $result = mysql_query($sql1) or die(mysql_error());
  12.             $row=mysql_fetch_array($result);
  13.             ?> <form name="form1" method="post" action="http://bytes.com/processupdatepage.php" class="formposition" enctype="multipart/form-data" > <table> <tr><td> <input type="hidden" name="id" value="<?php echo $row['id']; ?>" /></td></tr> <tr><td width="98">Image</td><td width="288">
  14.              // here my prob...i can't get my image value but other data value work very well.....
  15.              <input type="file" name="image" value="<?php echo $row['image'];?>" /></td></tr><br/> <tr><td>nane</td><td><input type="text" name="name" value="<?php echo $row['name']; ?>"/></td></tr><br/> <tr><td></td> <td colspan="2"> <input type="submit" name="submit" value="Save" /> </td></tr> </table> </form>
ok now this my process file

processupdatepage.php

Expand|Select|Wrap|Line Numbers
  1.         <?php
  2.         include("config.php");
  3.         $id=$_POST['id'];
  4.     $image=$_FILES['image']['name'];
  5.     $name=$_POST['name'];
  6.     $target = "http://bytes.com/images/"; 
  7.     $target = $target . basename( $_FILES['image']['name']);
  8.     $query = "UPDATE imagename SET name='$name', image='$image' WHERE id='$id'";
  9.         $bb = mysql_query($query) or die(mysql_error());
  10.     if($bb)
  11.     {
  12.     //Writes the photo to the server 
  13.          if(move_uploaded_file($_FILES['image']['tmp_name'], $target)) 
  14.          {  
  15.          $sql001="UPDATE imagename SET image='$image' WHERE image='$image'";
  16.         mysql_query($sql001);
  17.          } 
  18.          else { 
  19.          } 
  20.         header("Location:index.php");
  21.     }
  22.     else
  23.     {
  24.         echo "Could not be updated";
  25.     }
  26.         ?>
I can update BUT must select image...if i'm not select image, my image field in database will be empty BUT other data update OK...

sorry for my bad english...
Dec 18 '12 #1
1 3518
Rabbit
12,516 Expert Mod 8TB
What's wrong with that? If they don't select an image, then it should be empty in the database. Why would you populate an image in the database that they didn't choose?
Dec 18 '12 #2

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

Similar topics

2
by: Derek Scollon | last post by:
Hope someone can point me in the right direction to fix this one... I'm currently running Apache 2.0.40 and PHP 4.2.2 on a RedHat9 server. I'm needing to update to PHP5 but don't want to change...
1
by: Sure | last post by:
Hello All, I want to update a form using the LWP & HTTP method. It was working fine when I am updating the values like this $ua = LWP::UserAgent->new; $url...
3
by: Bhavin | last post by:
Hi I'm trying to update time field which MSACCESS using query Sql2 = "Update tblExtraNetUsers SET Lo_date = " & Date() & ",Lo_time =#" & FormatDateTime(Time(),4) &"# ,Lo_count = " &...
1
by: j.mandala | last post by:
I have a memo field in an appointment application that stores session notes for group psychotherapy sessions. Each attendee of the group has an appointment record. I want to be able to write a...
0
by: cronman | last post by:
I am creating a small Windows application using Visual C# 2005 Express Edition (August CTP) for a small non-profit agency. My current issue is with updating related information in an Access...
14
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these...
2
by: thehuby | last post by:
I am building a CMS and as part of it a user can upload an image. Once uploaded I am displaying the image. If the user then decides they want to replace the image with another I get a caching...
8
by: veerapureddy | last post by:
Hai everybody, I am facing problem with updating a record .actullay im getting some data from database(Access) and populating it on a html form.im trying to edit some texts and update, its not...
2
by: avvarumurali | last post by:
Hi, iam doing c# windows application. i save a image into the database,but iam unable to retrive image from database it is giving error "parameter is not valid "; mycode is : string query =...
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
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.