473,698 Members | 2,132 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 1408
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
33930
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
2486
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
1426
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
1560
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
3394
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
4168
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
2681
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
8600
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
9156
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8892
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8860
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...
0
7712
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5860
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
4614
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3038
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
3
1998
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.