title: Making a Like/Dislike AJAX script - Not working
body: <p>I'm just building the like side of it first. Basically, I just want it to automatically run an external PHP/MySQL script that adds a +1 to the "rating" column for what was liked. I want this to happen without reloading the page, hence AJAX. I've never used AJAX and I'm having some trouble getting it to work. Below is the relevant code and I put a link to where I'm working on it at at the bottom of this post.</p>
  
  <p>Here's the form to start:</p>
  
  <pre><code>&lt;div id="voting"&gt;    
  &lt;form&gt;   
    &lt;input name="vote" type='button' onclick="getVote(&lt;?php echo $image['filename'];?&gt;)" value='Like' /&gt; 
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here's the AJAX part of it:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function getVote(filename)
  {
  if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
  else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
      {
      document.getElementById("voting").innerHTML=xmlhttp.responseText;
      }
    }
  xmlhttp.open("GET","voting.php"+filename,true);
  xmlhttp.send();
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>And finally, the voting.php script that's supposed to run:</p>
  
  <pre><code>&lt;?php
  //Database Information
  $dbhost = "";
  $dbname = "";
  $dbuser = "";
  $dbpass = "";
  
  //Connect to database
  mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
  mysql_select_db($dbname) or die(mysql_error());
  
  $filename = $_GET['filename'];
  
  $query = "UPDATE images SET rating = rating+1 WHERE filename = '$filename'";
  
  mysql_query($query) or die(mysql_error());
  mysql_close();
  
  ?&gt; 
  </code></pre>
  
  <p><a href="http://www.ewsprojects.com/~lyons" rel="nofollow">Here</a>'s the site it's supposed to go on if it's of any help to anyone. I'd really appreciate any kind of help. Absolutely clueless and I've never used AJAX before. Thanks in advance!</p>