Jasen Hicks Posted February 1, 2007 Share Posted February 1, 2007 Ok, after many trials and tribulations I managed to get my script running. It is for accessing a database, adding to it, editing entries, or deleting entries. Its for a reef club, so its all about fish/corals. Basically, when I add/edit an entry from the Mac... no problems, it works fine. When I try and do the same thing from the PC, it says it worked but it actually did absolutely nothing. Here is the code for the input file: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>TRS Compatability Input</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type="text/javascript" language="javascript"> function CheckData(){ if(document.form.name.value.length <=0 || document.form.name.value == "***Creature Name"){ alert("Enter a Creature Name."); document.form.name.value="***Creature Name"; document.form.focus(); var problem = true; } if(problem == true){ return false; } else{ return true; } } </script> </head> <body> <h4><font face="Verdana, Arial, Helvetica, sans-serif">TRS Compatability Database :: Enter a new Creature</font> </h4> <FORM ACTION=databaseAdd.php ENCTYPE=multipart/form-data name=form onSubmit="return CheckData()"> <table width="483" border="0" cellspacing="2" cellpadding="2"> <tr align="left" valign="top"> <td width="94"> <p><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Name:</font></p></td> <td width="389"><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> <input name="name" type="text" id="name" size="50" maxlength="100"> </font></td> </tr> <tr align="left" valign="top"> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Care Level:</font></td> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> <select name="careLevel" id="careLevel"> <option value="Easy" selected>Easy</option> <option value="Moderate">Moderate</option> <option value="Difficult">Difficult</option> <option value="Expert Only">Expert Only</option> </select> </font></td> </tr> <tr align="left" valign="top"> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Temperment:</font></td> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> <select name="temperment" id="temperment"> <option value="Docile" selected>Docile</option> <option value="Peaceful">Peaceful</option> <option value="Moderate">Moderate</option> <option value="Bold">Bold</option> <option value="Aggressive">Aggressive</option> </select> </font></td> </tr> <tr align="left" valign="top"> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Reef Safe:</font></td> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> <input name="reefSafe" type="radio" value="Yes" checked> Yes <input name="reefSafe" type="radio" value="No"> No </font></td> </tr> <tr align="left" valign="top"> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Acclimation Time (Hours):</font></td> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> <select name="acclimationTime" id="acclimationTime"> <option value="1" selected>1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> </select> </font></td> </tr> <tr align="left" valign="top"> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Minimum Tank Size:</font></td> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> <select name="tankSize" id="tankSize"> <option value="20">20</option> <option value="30">30</option> <option value="40">40</option> <option value="55" selected>55</option> <option value="75">75</option> <option value="100">100</option> <option value="125">125</option> <option value="150">150</option> <option value="200">200</option> <option value="250">250</option> </select> </font></td> </tr> <tr align="left" valign="top"> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Lighting Requirements:</font></td> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> <select name="lighting" id="lighting"> <option value="Non-Photosynthetic" selected>Non-Photosynthetic</option> <option value="Low">Low</option> <option value="Low - Medium">Low - Medium</option> <option value="Medium">Medium</option> <option value="Medium - Strong">Medium - Strong</option> <option value="Strong">Strong</option> </select> </font></td> </tr> <tr align="left" valign="top"> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">First Food Enjoyed:</font></td> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> <select name="Diet1" id="select"> <option value="Pellet">Pellet</option> <option value="Flake">Flake</option> <option value="Mysid" selected>Mysid</option> <option value="Brine">Brine</option> <option value="Packaged Food">Packaged Food</option> <option value="Greens">Greens</option> <option value="Krill">Krill</option> <option value="Clams">Clams</option> <option value="Meaty">Meaty</option> <option value="Algae">Algae</option> <option value="Coral Food">Coral Food</option> <option value="Live Shrimp">Live Shrimp</option> <option value="Ghost Shrimp">Ghost Shrimp</option> <option value="Feeder Shrimp">Feeder Shrimp</option> <option value="Sponge Base">Sponge Base</option> </select> </font></td> </tr> <tr align="left" valign="top"> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Second Food Enjoyed:</font></td> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> <select name="Diet2" id="select2"> <option value="" selected="selected"></option> <option value="Pellet">Pellet</option> <option value="Flake">Flake</option> <option value="Mysid">Mysid</option> <option value="Brine">Brine</option> <option value="Packaged Food">Packaged Food</option> <option value="Greens">Greens</option> <option value="Krill">Krill</option> <option value="Clams">Clams</option> <option value="Meaty">Meaty</option> <option value="Algae">Algae</option> <option value="Coral Food">Coral Food</option> <option value="Live Shrimp">Live Shrimp</option> <option value="Ghost Shrimp">Ghost Shrimp</option> <option value="Feeder Shrimp">Feeder Shrimp</option> <option value="Sponge Base">Sponge Base</option> </select> </font></td> </tr> <tr align="left" valign="top"> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> Third Food Enjoyed:</font></td> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> <select name="Diet3" id="select3"> <option value="" selected="selected"></option> <option value="Pellet">Pellet</option> <option value="Flake">Flake</option> <option value="Mysid">Mysid</option> <option value="Brine">Brine</option> <option value="Packaged Food">Packaged Food</option> <option value="Greens">Greens</option> <option value="Krill">Krill</option> <option value="Clams">Clams</option> <option value="Meaty">Meaty</option> <option value="Algae">Algae</option> <option value="Coral Food">Coral Food</option> <option value="Live Shrimp">Live Shrimp</option> <option value="Ghost Shrimp">Ghost Shrimp</option> <option value="Feeder Shrimp">Feeder Shrimp</option> <option value="Sponge Base">Sponge Base</option> </select> </font></td> </tr> <tr align="left" valign="top"> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Flow Requirements:</font></td> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> <select name="flow" id="flow"> <option value="Low" selected>Low</option> <option value="Low - Medium">Low - Medium</option> <option value="Medium">Medium</option> <option value="Medium - High">Medium - High</option> <option value="High">High</option> <option value="Very High">Very High</option> </select> </font></td> </tr> <tr align="left" valign="top"> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Notes:</font></td> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> <textarea name="notes" cols="50" rows="10" id="notes"></textarea> </font></td> </tr> <tr align="left" valign="top"> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Known Antagonists:</font></td> <td><font size="-1" face="Verdana, Arial, Helvetica, sans-serif"> <textarea name="antagonist" cols="50" rows="10" id="antagonist"></textarea> </font></td> </tr> <tr align="left" valign="top"> <td><label> </label> <font size="-1" face="Verdana, Arial, Helvetica, sans-serif">Image:</font></td> <td> <input name="file" type="file" size="40"> </td> </tr> <tr align="left" valign="top"> <td colspan="2"><div align="center"> <input type="submit" name="Submit" value="Submit"> <input type="reset" name="Reset" value="Reset"> </div></td> </tr> </table> </FORM> </body> </html> Here is the databaseAdd.php code: <? require("includes/database.php"); $link = database_connect(); //START IMAGE PROCESSING // ============== // Configuration // ============== $path = "/hermes/web10/b2812/pow.twr/htdocs/compatability/"; $uploaddir = "images"; // Where you want the files to upload to - Important: Make sure this folders permissions is 0777! $allowed_ext = "jpg"; // These are the allowed extensions of the files that are uploaded $allowed_ext2 = "JPG"; $allowed_ext3 = "gif"; $allowed_ext4 = "GIF"; $max_size = "500000"; // 50000 is the same as 50kb $max_height = "500"; // This is in pixels - Leave this field empty if you don't want to upload images $max_width = "500"; // This is in pixels - Leave this field empty if you don't want to upload images // Check Entension $extension = pathinfo($_FILES['file']['name']); $extension = $extension[extension]; $ok = "1"; // Check File Size if ($ok == "1") { if($_FILES['file']['size'] > $max_size) { print "<font size=\"-1\" face=\"Verdana\">The image exceeded the 500KB Limit, please try again.</font>"; exit; } // Check Height & Width if ($max_width && $max_height) { list($width, $height, $type, $w) = getimagesize($_FILES['file']['tmp_name']); if($width > $max_width || $height > $max_height) { print "<font size=\"-1\" face=\"Verdana\">Image dimension are too big. Image must be 500X500 or lower.</font>"; exit; } } // The Upload Part if(is_uploaded_file($_FILES['file']['tmp_name'])) { move_uploaded_file($_FILES['file']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']); } $image = $_FILES['file']['name']; $permission = $path.$uploaddir.'/'.$image; chmod("$permission", 0755); //if(chmod("$permission", 0755)) //{ //echo "Permission Set<BR><BR>"; //} //else //{ //echo "DOH!"; //} //print "<font size=\"-1\" face=\"Verdana\">The image has been uploaded successfully.</font><BR><BR>"; //echo "$image"; //$imagetype = $_FILES['file']['type']; //echo "<BR><BR>$imagetype"; //echo"<BR> <BR> <IMG SRC=$uploaddir/$image>"; } else { print "<font size=\"-1\" face=\"Verdana\">Incorrect file extension, only JPG/GIF files are allowed to be uploaded.</font>"; } //END IMAGE PROCESSING $result = mysql_query("INSERT INTO compatability (name, careLevel, temperment, reefSafe, acclimationTime, tankSize, lighting, Diet1, Diet2, Diet3, flow, notes, antagonist, image) VALUES(\"$HTTP_POST_VARS[name]\", \"$HTTP_POST_VARS[careLevel]\", \"$HTTP_POST_VARS[temperment]\", \"$HTTP_POST_VARS[reefSafe]\", \"$HTTP_POST_VARS[acclimationTime]\", \"$HTTP_POST_VARS[tankSize]\", \"$HTTP_POST_VARS[lighting]\", \"$HTTP_POST_VARS[Diet1]\", \"$HTTP_POST_VARS[Diet2]\", \"$HTTP_POST_VARS[Diet3]\", \"$HTTP_POST_VARS[flow]\", \"$HTTP_POST_VARS[notes]\", \"$HTTP_POST_VARS[antagonist]\", \"$image\")"); if ($result) { // $lastEntry = mysql_insert_id(); //header("Location: compatabilityProfile.php?id=$lastEntry"); //header("Location: compatabilityResults.php"); echo "Added."; database_close($link); } else { echo "<B>Failed to Add to the Database</B><BR><BR>"; echo mysql_error(); } database_close($link); // header("Location: compatabilityProfile.php?id=$new"); ?> Quote Link to comment Share on other sites More sharing options...
HoTDaWg Posted February 1, 2007 Share Posted February 1, 2007 well there could be a variety of reasons: - are you sure you used the same browser? - are you sure your computer is pretty virus/trojan free? - are you sure your internet/network for your computer AND your website were both functional at the time? - are you sure your html/xhtml coding is correct? - do all fields in the html match the fields mentioned in the php? as you probably know, PHP scripts are ran of the SERVER not the person's computer therefore, if the script works on your Mac it should work on your PC. haha, these remind of those mac and PC commercials. they are pretty funny. HoTDaWg Quote Link to comment Share on other sites More sharing options...
Jasen Hicks Posted February 1, 2007 Author Share Posted February 1, 2007 well there could be a variety of reasons: - are you sure you used the same browser? - are you sure your computer is pretty virus/trojan free? - are you sure your internet/network for your computer AND your website were both functional at the time? - are you sure your html/xhtml coding is correct? - do all fields in the html match the fields mentioned in the php? as you probably know, PHP scripts are ran of the SERVER not the person's computer therefore, if the script works on your Mac it should work on your PC. haha, these remind of those mac and PC commercials. they are pretty funny. HoTDaWg 1. Same browser no, I use Safari on the Mac, IE on the PC. Shouldnt matter though i thought, as PHP all is executed on the server. 2. The PC has no virus on it, and on other PCs it doesnt work. 3. As far as I can tell all the coding is correct. If not, thats why I posted it here so maybe someone can see an error somwhere that I missed. 4. All the variables should be fine, as I said when I run the script from my MAC it executes 100% and puts everything in the database fine. 5. And yes both are connected to the internet when I run them... i have to be, the scripts are all on my webserver. I run nothing from either computer, I run it all via thier browsers after I have put it up on the website. Jasen Quote Link to comment Share on other sites More sharing options...
matto Posted February 1, 2007 Share Posted February 1, 2007 This style of code is the old way of doing things $HTTP_POST_VARS[name] the above should now be..... $_POST['name'] Quote Link to comment Share on other sites More sharing options...
Kano Posted February 1, 2007 Share Posted February 1, 2007 The first font tag inside the body tag has not been closed? You should really rewrite this in xhtml (see www.htmldog for advice) and css. Quote Link to comment Share on other sites More sharing options...
Kano Posted February 1, 2007 Share Posted February 1, 2007 Maybe you should change your charset to utf-8 Not sure these things will help your problem but they are good practice Quote Link to comment Share on other sites More sharing options...
Cep Posted February 1, 2007 Share Posted February 1, 2007 Think I would want to clarify what you mean by "it worked" and "it did nothing". What does your script do precisely and what does it not do precisely on the PC? As mentioned by others PHP is server side so there should be no reason for any difference on the server side result. If your crossplatform coding your client side it should definately be written in XHTML. Quote Link to comment Share on other sites More sharing options...
Jasen Hicks Posted February 1, 2007 Author Share Posted February 1, 2007 Think I would want to clarify what you mean by "it worked" and "it did nothing". What does your script do precisely and what does it not do precisely on the PC? As mentioned by others PHP is server side so there should be no reason for any difference on the server side result. If your crossplatform coding your client side it should definately be written in XHTML. Ok, when I run the script from my MAC using Safari, it makes it all the way through the script i.e. adds the data to the databse or edits it (depending on the file either add or edit) and then it says "Added." Then i can actually see it in the reults list ( a different file to show database entriesd ). When I run it on the PC using internet explorer, it makes it all the way through the script and at the end shows the exact same thing as when I run it on the MAC (end result says "Added.") but when i accss the script that displays all data, whatever i just added or edited doesnt show it or any changes. Im not doing anything crazy here, its a pretty simple thing so i dont want to overcomplicate by getting into XHTML and learning all that stuff... Im a nuclear engineer and reef aquarium hobbiest with enough php and html knowledge to be dangerous. Ill try changing my POSTs to what KANO reccomended.... but i dont think it will help.... but ill try. I want to be upto date, all my codes and books are from php 4 Quote Link to comment Share on other sites More sharing options...
Kano Posted February 2, 2007 Share Posted February 2, 2007 Jasen dude, xhtml is so simple man, its worth looking at someday when you get chance. www.htmldog.com explains how to code in xhtml and css in a way that even george bush could grasp it! I apologize in advance to all the yanks, not! Quote Link to comment Share on other sites More sharing options...
Kano Posted February 2, 2007 Share Posted February 2, 2007 sorry for my first posting I did not realise that there was a horizontal scroll for the code you submitted Quote Link to comment Share on other sites More sharing options...
Kano Posted February 2, 2007 Share Posted February 2, 2007 Mate, what is the reason for this statement - if ($max_width && $max_height) Quote Link to comment Share on other sites More sharing options...
Kano Posted February 2, 2007 Share Posted February 2, 2007 Your problem my lie in this script - compatabilityResults.php Quote Link to comment Share on other sites More sharing options...
Jasen Hicks Posted February 3, 2007 Author Share Posted February 3, 2007 I got a book on XHTML and set dreamweaver to XHTML Strict 1.0.. Recoded everything too... none of the PHP was bad, just out dated... the big thing i found was one of my forms was missing a method=post... fixed everything. I feel dumb now. After reading up on the XHTML and realizing that it was a simple setting in dreamweaver i wont ever go any other way. Thanks for everyones help and recommendations. Jasen Quote Link to comment Share on other sites More sharing options...
Kano Posted February 5, 2007 Share Posted February 5, 2007 Dude, just an opinion but Dreamweaver should only be used for prototypes, you should really code using notepad (or similar) as Dreamweaver produces nasty code Quote Link to comment Share on other sites More sharing options...
Cep Posted February 20, 2007 Share Posted February 20, 2007 Dude, just an opinion but Dreamweaver should only be used for prototypes, you should really code using notepad (or similar) as Dreamweaver produces nasty code Agreed! Never use wysiwyg! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.