Hey everyone
Hope you can help me out here I have two scripts
here is one
<html>
<head>
<title> Movie Search</title>
<style type="test/css">
table{
background color: #FCF;
}
th {
width: 150px;
text-align: left;
}
</style>
</head>
<body>
<h1> Movie Search</h1>
<form method="post" action="search1.php">
<input type="hidden" name="submitted" value="true" />
<label> Search Category:
<select name="category">
<option value="movie_id">Movie id</option>
<option value="title">Movie title</option>
<option value="genre">Genre</option>
<option value="director">Director</option>
<option value="production_year">Production year</option>
<option value="media_types">Media_types</option>
<option value="duration">Duration</option>
</select>
</label>
<label> Search Criteria: <input type= "text" name="criteria" /></label>
<input type="submit" />
</form>
<?php
if (isset($_POST['submitted'])) {
//connect to database
include('connect.php');
$category = $_POST['category'];
$criteria = $_POST['criteria'];
$query = "SELECT * FROM movies WHERE $category = '$criteria'";
$result = mysqli_query ('$dbcon', '$query') or die(error getting data);
echo "<table>";
echo "<tr><th>Movie_ID</th><th>Title</th> <th>Genre</th> <th>Director</th> <th>Production_year</th> <th>Production_company</th> <th>Media_types</th> <th>Duraction</th> </tr>";
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
echo "<tr><td>";
echo $row['movie_id'];
echo "</td><td>";
echo $row['title'];
echo "</td><td>";
echo $row['genre'];
echo "</td><td>";
echo $row['director'];
echo "</td><td>";
echo $row['production_year'];
echo "</td><td>";
echo $row['production_company'];
echo "</td><td>";
echo $row['media_types'];
echo "</td><td>";
echo $row['duration'];
echo "</td></tr>";
}
echo "</table>";
}
?>
</body>
</html>
here is two
<?php
mysql_connect("localhost", "root", "123") or die (mysql_error());
echo "Connected to MySQL<br/><hr />";
mysql_select_db("movies") or die (mysql_error());
echo "Connected to Database<br /><hr /";
$dbcon = mysqli_connect("localhost", "root", "123", "movies");
?>
I am getting the following error
Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\databases\search1.php on line 53
Anyone have any ideas?
I'm not sure if its the actual script that's the problem or if there is an issue connecting to my database because strangely my connect.php file sometimes generates the echo sometimes not :glare:
Thanks in advance