473,722 Members | 2,161 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

my code works perfectly for one input box but not the other

tolkienarda
316 Contributor
hi all

have finnaly figured out how this php script works. i have been trying to modify it for some time but i sturgled because i had no idea what the logic behind it was but finally i figured it out and have made it work, almost. the pourpose is for the script to upload and image into a database overighting an older one. this is just used for a super simple content management service. the first form will upload its image and display the new one just fine but the second form (which is identical) wont upload any images my code is below

[PHP]
<?
$host="localhos t"; // Host name.
$db_user="****" ; // MySQL username.
$db_password="* ******"; // MySQL password.
$database="cms" ; // Database name.
$cms = mysql_pconnect( $host, $db_user, $db_password) or trigger_error(m ysql_error(),E_ USER_ERROR);
mysql_select_db ($database, $cms);
$errmsg="";
if ($_POST[completed] == 'submitted')
{
$testval = "set";
move_uploaded_f ile($_FILES['imagefile']['tmp_name'],"latest.img ");
$instr = fopen("latest.i mg","rb");
$image = addslashes(frea d($instr,filesi ze("latest.img" )));
$location = $_REQUEST[location];
if (strlen($instr) < 149000) {
//mysql_query ("INSERT INTO pix (pid, title, imgdata, location) VALUES ('NULL', '$_REQUEST[whatsit]', '$image', '$location')");
mysql_query("UP DATE pix SET imgdata = '$image' WHERE location='$loca tion'");
} else {
$errmsg = "Too large!";
}
}


// below is how my image gets printed
$page = "home";
$position = $_REQUEST[gim];
$locationval = $page . $position;
$gotten = mysql_query("SE LECT * FROM pix WHERE location='$loca tionval'");

if ($row = mysql_fetch_ass oc($gotten))
{
$bytes = $row[imgdata];
header("Content-type: image/jpeg");
print $bytes;
exit ();
}
?>


<html><head>
<title>Upload image</title>

<center><img src=?gim=1 width=144><br>
<b></center>
<form enctype='multip art/form-data' method='post'>
<input type='hidden' name='MAX_FILE_ SIZE' value='150000'>
<input type='hidden' name='completed ' value='submitte d'>
browse: <input type='file' name='imagefile '><br>
<input type="hidden" name="location" value="home1">
then: <input type='submit'></form><br>




<center><img src=?gim=2 width=144><br>
<b></center>
<form enctype='multip art/form-data' method='post'>
<input type='hidden' name='MAX_FILE_ SIZE' value='150000'>
<input type='hidden' name='completed ' value='1'>
browse: <input type='file' name='imagefile '><br>
<input type="hidden" name="location" value="home2">
then: <input type='submit'></form><br>


</body>
</html>

[/PHP]

thanks for any input
Mar 5 '07 #1
2 1410
tolkienarda
316 Contributor
nevermind i forgot that i change done of the forms for error checking

eric
Mar 5 '07 #2
ronverdonk
4,258 Recognized Expert Specialist
Can happen to anyone.

Ronald :cool:
Mar 5 '07 #3

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

Similar topics

699
34015
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro capabilities, unfortunately. I'd like to know if it may be possible to add a powerful macro system to Python, while keeping its amazing syntax, and if it could be possible to add Pythonistic syntax to Lisp or Scheme, while keeping all of the...
2
2487
by: Sergio del Amo | last post by:
Hi, I wrote some functionality for a Web Page with Javascript. My code works perfectly for Firefox but not for IE. I become some errors apparently all based in the same problem wich scapes to my knowledge. If anyone can help me, i would be really grateful. These are the errors i was speaking about: -------------------------------------------- Line: 58
9
2059
by: Dave Brydon | last post by:
Access 2003: I currently apply my Postal/Zip Code Format based off the Country Selected; the way I do it is by checking on the country; using the forms "On Current" event procedure, then I use additional code on my Postal/Zip Code field, using the fields "On Got Focus" event (Code Below) to manipulate the input mask. This procedure works well; however, I now wish to have a longer Value List of countries instead of using "Other", but I...
1
1429
by: ILCSP | last post by:
Hi,this has been bothering me for a while now. I have 2 MS Access 2000 databases, the real one that everybody uses (in the NT network) and the one I use to design new stuff. After I test the new forms on mine, I import them to the real database so everybody can use it. However, some of the code that works perfectly in my design database fails when I import the form to the network database. Sometimes the code is as simple as...
9
1562
by: cyberscout | last post by:
OK I have some code which I didn't write and I'm toying with whether I need to tidy it up. In the code is the line shown in Example 1 Exampe 1: sprintf(stringvariable, "%s", "String"); Is it any worse than simply putting.
7
3395
by: Rich_C | last post by:
I'm able to clone a table row using this: function insert(btn) {var cell, newRow, row, sect; if((cell = btn.parentNode) && (row = cell.parentNode) && row.cloneNode && (sect = row.parentNode) && sect.insertBefore) { newRow = row.cloneNode(true); /* If you need to alter the new row * or its contents, do it here. */
3
4169
by: aryayudhi | last post by:
I have a html page that has javascript that works perfectly in IE, but not in Firefox. The use of this javascript to change "Tab" to "Enter" Button. When we press Tab, it is like when we press Enter button. How to make this script can be run on Firefox? I would be grateful to anybody who can help me on this, as I have got out of my depth with this problem. Thanks, Arya ======== This is the script : <script language="javascript"...
1
2683
by: reemamg | last post by:
I've two frames in a page. On the left Frame i've buttons , if we click on button the particular pages will be loaded in the middle Frame. This code works perfectly in Firefox but not in IE ... Please help me to resolve this issue.. <html> <head> <!-- Infrastructure code for the tree -->
0
8863
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9238
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9088
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6681
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5995
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4502
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.