title: Contacting an API, Error's just some of the time...?
body: <p>I have written PHP code which connects to MYSQL to look up information, sends it to an API, and get a response to write back into a new table. </p>
  
  <p>Sometimes it works perfectly, other times it doesn't. When it doesn't it gives me this error </p>
  
  <pre><code>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' , , '', '', '')' at line 1
  </code></pre>
  
  <p>or sometimes it will write one or two entries into the new table and then give me the error at a different line. Oh, and even if I choose the same data for the API to look up and send, sometimes it will work and sometimes it won't.( I have taken all commas out of the strings that are being sent to cut back on possible errors with commas.)</p>
  
  <p>I'm wondering if this is a problem with the API or my code. I can't understand how it would work for some of the time, and be a problem on the code problem, which leads to my thoughts on possible API problems.</p>
  
  <p>My hypotheses are:</p>
  
  <ol>
  <li>The API key I have has limited functionality and so limits my results.</li>
  <li>It takes to long for a response and so times out my request. </li>
  </ol>
  
  <p>Do either of these make sense? Any other ideas?</p>
  
  <p>Here's the php code that sometimes gets back something:</p>
  
  <p>Sometimes it will echo out. But othertimes it won't. The function $request->whatever are available in the API functions php. </p>
  
  <p>I believe the sql line that is throwing the error has to do with this:</p>
  
  <pre><code>insertRow($db, $new_table, $Merchant, $ips, $scoreBeforeGeo, $geoFactor, $scoreAfterGeo, $category, $overall_protocol, $protocol_name);
  
  function insertRow($db, $new_table, $Merchant, $ips, $scoreBefore, $geoFactor,      $scoreAfter, $category, $overall, $protocol)
  {
     $insert = "INSERT INTO $new_table " . " VALUES('$Merchant', '$ips', $scoreBefore, $geoFactor, $scoreAfter, '$category', '$overall', '$protocol');";
  $q = mysqli_query($db, $insert) || die(mysqli_error($db));
  }
  </code></pre>
  
  <p>Again, sometimes it works and sometimes it doesn't....</p>