title: Getting Mysql_Close Error
body: <p>I am receiving a mysql_close() error for the bellow code, although as I see it the syntax is correct. It opens fine, the variable is correct. Any suggestions? Code is live here (http://obsidianpunch.com/Summer) error is Warning: mysql_close(): 5 is not a valid MySQL-Link resource in /home/content/53/7382753/html/Summer/wootsummer.php on line 97</p>
  
  <p>line 97 is</p>
  
  <pre><code>mysql_close($con);
  </code></pre>
  
  <p>Here is wootsummer.php</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
  &lt;?php
  
  error_reporting(E_ALL);
  set_time_limit (0);
  
  $urls=explode("\n", $_POST['url']);
  //$proxies=explode("\n", $_POST['proxy']);
  
  $target=$_POST['target'];
  
  $allurls=count($urls);
  //$allproxies=count($proxies);
  
  //use the new tool box
  require "ToolBoxA4.php";
  
  
  for ( $counter = 0; $counter &lt; $allurls; $counter++) {
  //for ( $count = 0; $count &lt;= $allproxies; $count++) {
  
  
   $ch = curl_init();
   curl_setopt($ch, CURLOPT_URL,$urls[$counter]);
   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'GET');
   curl_setopt ($ch, CURLOPT_HEADER, 1); 
   curl_exec ($ch); 
   $curl_scraped_page=curl_exec($ch); 
  
  
  //call the new function parseA1
  $arrOut = parseA1 ($curl_scraped_page);
  
  
  $curl_scraped_page=strtolower($curl_scraped_page);
  $haystack=$curl_scraped_page;
  if (strlen(strstr($haystack,$target))&gt;0) {
  
  
  
  $FileName = abs(rand(0,100000));
  $FileHandle = fopen($FileName, 'w') or die("can't open file");
  fwrite($FileHandle, $curl_scraped_page);
  
  
  $hostname="*******";
  $username="hatrick";
  $password="*******";
  $dbname="hatrick";
  $usertable="happyturtle";
  
  $con=mysql_connect($hostname,$username, $password) or die ("&lt;html&gt;&lt;script language='JavaScript'&gt;alert('Unable to connect to database! Please try again later.'),history.go(-1)&lt;/script&gt;&lt;/html&gt;");
  mysql_select_db($dbname ,$con);
  if (!$con)
     {
     die(mysql_error());
     }
   mysql_close($con);
  
  $right = explode(",", $arrOut[0]);
  $top = explode(",", $arrOut[1]);
  
  for ( $countforme = 0; $countforme &lt; 6; $countforme++) {
  //$topnow=$top[$countforme];
  //echo '$topnow';
  
  $query = "INSERT INTO happyturtle (time, ad1) VALUES ('00987','www.hats.com')";
  //mysql_query($query) or die('Error, insert query failed');
  if (!$query)
     {
     die(mysql_error());
     }
   //mysql_close($con);
  
  
  }
  
  for ( $countforme = 0; $countforme &lt;= 15; $countforme++) {
  
  //$rightnow = $right[$countforme];
  
  
  $query = "INSERT INTO happyturtle (time, ad1) VALUES ('00987','www.hats.com')";
  //mysql_query($query) or die('Error, insert query failed');
  if (!$query)
     {
     die(mysql_error());
     }
   //mysql_close($con);
  
  }
  
  mysql_close($con);
  
  
  echo '$FileNameSQL';
  
  
  fclose($FileHandle);
  }
  curl_close($ch);
  
  }
  
  
  
  ?&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thank You!</p>