I have to create a offline movie website with localhost in PHP. Somehow I can't get the search right and would be nice if anyone could explain to me why. The search is supposed to search by a word in the title, year, genre of director. Don't mind the CSS just want it to work for now :)
Here's what I got so far and the error it gives.
<form action="../PHP/moviedirectory.php" method="post">
<input type="text" name="search" placeholder="zoeken.."/>
</form>
<?php
$link = mysqli_connect("localhost", "*User*", "*Password*", "WEBSITE");
$searchq = null;
if (isset($_POST['search'])) {
global $searchq;
$searchq = $_POST['search'];
}
$query = mysqli_query($link, "SELECT * FROM WEBSITE.dbo.movie WHERE title
LIKE '%$searchq%' ORDER BY publication_year AND title DESC") or die("could
not search!");
$query = mysqli_query($link, "SELECT * FROM WEBSITE.dbo.movie WHERE
publication_year LIKE '%$searchq%' ORDER BY publication_year AND title
DESC") or die("could not search!");
$query = mysqli_query($link, "SELECT * FROM WEBSITE.dbo.movie WHERE genre
LIKE '%$searchq%' ORDER BY publication_year AND title DESC") or die("could
not search!");
$query = mysqli_query($link, "SELECT * FROM WEBSITE.dbo.movie WHERE director
LIKE '%$searchq%' ORDER BY publication_year AND title DESC") or die("could
not search!");
$count = mysqli_num_rows($query);
$bla = mysqli_fetch_array($query);
$result = mysqli_fetch_all($query);
$title = $bla['title'];
$director = $bla['director'];
$description = $bla['description'];
$cast = $bla['bla'];
$duration = $bla['duration'];
$year = $bla['year'];
$img = $bla['img'];
$url = $bla['url'];
$genre = $bla['genre'];
Error:
Warning: mysqli_connect(): (HY000/2002): Can not connect because the target computer has actively declined the connection. in C:\xampp\htdocs\php\test\zoeken.php on line 6
Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in C:\xampp\htdocs\php\test\zoeken.php on line 13 could not search!