I have an html form which brings up an input box, which is this

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8"/>
<link rel="STYLESHEET" type="text/css" href="../../style/Browse.css">


<form name="input" action="Browsing.php" method="post">
Search <input type="text" name="search" />
<input type="submit" value="Submit" />



Then I have a php page which handles the input from that html page, the code is this


      $search= $_POST['search'];
      $con = mysql_connect("localhost","user","pass");
      if (!$con) {
      die('Could not connect: ' . mysql_error());

      mysql_select_db("db", $con); 
      $result = mysql_query("

      SELECT videos.videoname, videos.id_video 
      FROM videos
      WHERE videos.videoname=$search


        echo "Videos:";
      while ($row = mysql_fetch_array($result)) {
      echo "<div id=\"Search_Browse\">";
      echo "<a href='uploads/upload/browseplayer.php?num=$file_location'>$link</a>";
      echo "</div>";



But it does not display the code onto the page, it just puts ?search=example into the url box

Edited by pritaeas: Removed credentials

4 Years
Discussion Span
Last Post by broj1

If videos.videoname is a string you should enclose $search in quotes (line 14):

WHERE videos.videoname='$search'

Have you tried to debug the code by inserting echo, die or print_r debug statements like:

// in line 2 to check the value sent over

// or between lines 20 and 21 to check the values of row
die(print_r($row, 1)); 

// or between lines 9 and 10 to get the query and paste it to phpmyadmin
die("SELECT videos.videoname, videos.id_video FROM videos WHERE videos.videoname=$search");
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.