Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

I am trying to search a database by one of 4 table categories. a variable ‘q’ was assigned and trimmed to take and display the matched info from db and search criteria from user.

The database is currently populated with postal codes 10001. When I search Zip Code for this value the search returns 0 results. I am able to connect to local mySQL server, however when I try to connect to search the database I receive this error.

Could not retrieve Entries because: Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2). The query was SELECT * from pf_finder “%10001%” ORDER BY pf_clubName, pf_city, pf_zipcode, pf_artist.

html form


```html
 <form name="form" action="party_search.php" method="get">
  <select name="select">
    <option selected>Search by</option>

    <option value="name">Club Name</option>
    <option value="city">City</option>
    <option value="zipcode">Zip Code</option>
    <option value="date">Date</option>
  </select>
  <input type="text" name="q" />
  <input type="submit" name="Submit" value="Search" />
</form>


```php


  // Get the search variable from URL

  $var = @$_GET['q'] ;
  $trimmed = trim($var); //trim whitespace from the stored variable

// rows to return
$limit=5; 

// check for an empty string and display a message.
if ($trimmed == "")
  {
  echo "<p>Please enter a search category and type in your request.</p>";
  exit;
  }

// check for a search parameter
if (!isset($var))
  {
  echo "<p>We dont seem to have a search parameter!</p>";
  exit;
  }


if(isset ($_POST['submit'])) {//Handle form
// connect to MySQL database
include ('database.php');

} //Fixed Feb5



// Build SQL Query  
$query = "SELECT * from pf_finder \"%$trimmed%\"  
  ORDER BY pf_clubName, pf_city, pf_zipcode, pf_artist"; // table and field names for the SQL query

 $numresults=mysql_query($query);
 $numrows=mysql_num_rows($numresults);

// If we have no results, offer a google search as an alternative

if ($numrows == 0)
  {
  echo "<h4>Results</h4>";
  echo "<p>Sorry, your search: &quot;" . $trimmed . "&quot; returned zero results</p>
  <form action=''>
  <input type='button' name='Button' value='New Search'
  onClick = history.go(-1);>
</form>
(<i>If JavaScript is turned off you will have to use your browser's back button.</i>)
";

    echo "<p> Could not retrieve Entries because: <b>" .mysql_error() . "</b>. The query was $query. </p>";

  
  
// google
 echo "<p><a href=\"http://www.google.com/search?q=" 
  . $trimmed . "\" target=\"_blank\" title=\"Look up 
  " . $trimmed . " on Google\">Click here</a> to try a 
  search on google</p>";
  }

// next determine if s has been passed to script, if not use 0
  if (empty($s)) {
  $s=0;
  }

// get results
  $query .= " limit $s,$limit";
  $result = mysql_query($query) or die("Couldn't execute query");

// display what the person searched for
echo "<p>You searched for: &quot;" . $var . "&quot;</p>";

// begin to show results set
echo "Results";
$count = 1 + $s ;

// now you can display the results returned
  while ($row= mysql_fetch_array($result)) {
  $title = $row["1st_field"];//Place table display sequence here

  echo "$count.)&nbsp;$title" ;
  $count++ ;
  }

$currPage = (($s/$limit) + 1);

//break before paging
  echo "<br />";

  // next we need to do the links to other results
  if ($s>=1) { // bypass PREV link if s is 0
  $prevs=($s-$limit);
  print "&nbsp;<a href=\"$PHP_SELF?s=$prevs&q=$var\">&lt;&lt; 
  Prev 10</a>&nbsp&nbsp;";
  }

// calculate number of pages needing links
  $pages=intval($numrows/$limit);

// $pages now contains int of pages needed unless there is a remainder from division

  if ($numrows%$limit) {
  // has remainder so add one page
  $pages++;
  }

// check to see if last page
  if (!((($s+$limit)/$limit)==$pages) && $pages!=1) {

  // not last page so give NEXT link
  $news=$s+$limit;

  echo "&nbsp;<a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 &gt;&gt;</a>";
  }

$a = $s + ($limit) ;
  if ($a > $numrows) { $a = $numrows ; }
  $b = $s + 1 ;
  echo "<p>Showing results $b to $a of $numrows</p>";