issues with my php data retrieving script

hey everyone

I’m really new to php


so basically this text keeps coming up

here are my two codes

‘connect.php’

<?php

DEFINE (‘DB_USER’, root);
DEFINE (‘DB_PSWD’, password);
DEFINE (‘DB_HOST’, localhost);
DEFINE (‘DB_NAME’, movies);

$dbcon = mysqli_connect(DB_HOST, DB_USER, DB_PSWD, DB_NAME);

?>

and search1.php

Movies Search
    table{
background-color: #FCF;

}
th {
width: 150px;
text-align: left;

}

Movie Search

   <form method="post" action="search1.php">
   <input type="hidden" name="submitted" value="true" />
   
   <label> Search Category:
       <select name="category">
       <option value="title">Title</option>
       <option value="genre">Genre</option>
       <option value="director">Director</option>
       
       </select>
       </label>
       
       <label> Search Criteria: <input type="text" name="criteria" /></label>
       <input type="submit" />
       
       </form>

}

<?php if (isset($_POST['submitted'])) { //connect to the database <?php include 'connect.php'?>

$category = $_POST[‘category’];
$criteria = $_POST[‘criteria’];
$query = “SELECT * FROM ‘movies’ WHERE '”$category"’ = ‘"$criteria"’";
$result = mysqli_query($query, $dbcon) or die (‘error getting data’);

echo “

”;
echo "";

while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){

echo “

”;

}

echo “

Movie_ID Title Genre Director
”;
echo $row[‘movie_id’];
echo “
”;
echo “
”;
echo $row[‘title’];
echo “
”;
echo “
”;
echo $row[‘genre’];
echo “
”;
echo “
”;
echo $row[‘director’];
echo “
”;

} // end of main if statement

?>

I got my codes from this guy on youtube http://www.youtube.com/user/rrphillips#p/search/5/IYmS5HRo6JI seems to be working for everyone else…

Would really appreciate your help

Thanks guys :smiley:

Hi there,

Change:
[php]//connect to the database

<?php include 'connect.php'?>[/php]

to:
[php]//connect to the database
include ‘connect.php’;[/php]

I tried that already and it didn’t make a difference :’( but thanks

I don’t know if it has something to do with actually connecting to the database… my connect script sometimes just publishes as plain code…

Sponsor our Newsletter | Privacy Policy | Terms of Service