Jump to content

Script Works from my Mac, but not my PC!


Jasen Hicks

Recommended Posts

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");

?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.