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

error message displaying when field isn't empty

17
Hi. For some reason when I choose to update details in a database, a field which displays the image name stored in a database is deemed to be empty when it isn't empty. Any feedback would be much appreciated.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php 
  3.  
  4.                 if ($error == true)
  5.                     {
  6.                         echo '<div style="padding:5px 10px 5px 10px; margin-top:20px;  border:2px solid #FF0000; color:#FF0000; width:345px;">'.$error.'</div>';
  7.                     }
  8.  
  9.             ?>     
  10.  
  11.             <form id="edit-form" action="" method="post" enctype="multipart/form-data">
  12.                 <input type="hidden" name="id" value="<?php echo $id; ?>" />
  13.  
  14. <table>
  15. <tr>
  16.                             <td><strong>Photo <span class="red">*</span></strong></td>
  17.                             <td><input type="hidden" name="size" value="350000" /><input type="text" value="<?php echo $photo; ?>" /><input type="file" name="photo" value="<?php echo $photo; ?>" /></td>
  18. </tr>
  19.  
  20.  
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.     include('connect.php');
  4.  
  5.     if (isset($_POST['submit']))
  6.         { 
  7.  
  8.             if (is_numeric($_POST['id']))
  9.             {
  10.                 $id = $_POST['id'];
  11.                 $price = mysql_real_escape_string(htmlspecialchars($_POST['price']));
  12.                 $rooms = mysql_real_escape_string(htmlspecialchars($_POST['rooms']));
  13.                 $address = mysql_real_escape_string(htmlspecialchars($_POST['address']));
  14.                 $description = mysql_real_escape_string(htmlspecialchars($_POST['description']));
  15.                 $photo = (mysql_real_escape_string($_FILES['photo']['name']));
  16.  
  17.  
  18.                     if ($price == '' ||  $rooms == '' || $address == '' || $description == '' || $photo =='')
  19.                     {
  20.  
  21.                         $error = 'ERROR TRYING TO UPDATE RECORD: Please fill in all required fields';
  22.  
  23.                         form($id, $price, $rooms, $address, $description, $photo, $error);
  24.  
  25.                     }
  26.  
  27.                     else
  28.                     {
  29.                         $folder = "./houses/";
  30.                         move_uploaded_file($_FILES["photo"]["tmp_name"] , "$folder".$_FILES["photo"]["name"]);
  31.  
  32.                         mysql_query("UPDATE house_info SET price='$price', rooms='$rooms', address='$address', description='$description', photo='$photo' WHERE id='$id'")
  33.                         or die(mysql_error()); 
  34.  
  35.                         header("Location:admin.php");
  36.  
  37.                     }
  38.  
Dec 21 '11 #1
0 1189

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

Similar topics

2
by: Xiao Tencas | last post by:
When trying to load a png image in GD, I get the error (Mozilla Firefox) "cannot display image, because it contains errors"; IE just shows an empty 'image-error' box. When loading a large enough...
12
by: Stephen Poley | last post by:
I have a report which prints data from a parent table and two child tables (Contract and Kosten). Because it is a bit long, I suppress some fields which are often empty, based on methods found in...
2
by: Aaron | last post by:
how can i configure asp.net so that whenever an error occurs it would show a blank page, not the default error message. Thanks.
1
by: satya.mahesh | last post by:
Hi All, I am working on a problem which "eliminates blank lines in export (between headings and when a heading is empty)". I want a macro which will do this job for me. For e.g: Heading1 ...
8
by: Jon Paal | last post by:
Compiler Error Message: BC30002: Type 'System.Management.ManagementObjectCollection' is not defined. Source Error: Imports System.Management .... Line 40: Dim moColl As...
7
by: Stale | last post by:
When you insert value to an empty span in IE, the browser will not add the needed space between spans. Example: function btnclick() { document.getElementById("sp2").innerHTML="KING" }...
2
by: mirianCalin | last post by:
hi.. im doing a site.. i have this registration form where the user must enter some information like name, phone_number, age, etc.. an error message should appear if #1: there is an empty...
2
maryjane9110024
by: maryjane9110024 | last post by:
I have a form that I created a hidden text field. I want to be able to send the person to an error page if that field has some kind of value, nothing specific, just as long as its not empty. I tried...
2
by: dnnddane | last post by:
Hi All, I try to create a sample asp.net ajax application in visual studio 2005. I have 1 textbox, 1 requirefieldvalidator and 1 button. All are in updatepanel. When I click the button and the...
1
by: burtonfigg | last post by:
I don't know how hard this is / isn't to do, but I wondered if it is possible to use Javascript / jQuery (I have the library included on the page I need to edit) to display a message below a text...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.