This is my html page, which takes in an input by the user and the searches the database for the word, also there is a function which is suppose to display the results here is the html code

<?php
require_once ( 'browsing.php' );
?>




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

<body>
<div id="search_box">
<form>
<form name="input" action="" method="post">
Search <input type="text" name="search" />
<input type="submit" value="Submit" />
</form>
</form>
</div>

<p><?= $browsing->searchbrowse() ?></p>



</body>

</html>

The function does not work, i keep getting this error

Fatal error: Call to a member function searchbrowse() on a non-object in D:\Hosting\9791131\html\uploads\upload\browse.php on line 26

This is the code for the funtion

<?php
     function searchbrowse()
    {

if (isset($_POST['search'])) {

      $search= $_POST['search'];
      $con = mysql_connect("host.com","xxxx","xxxx");
      if (!$con) {
      die('Could not connect: ' . mysql_error());
      }

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

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

      "); 


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

      mysql_close($con);


       }
}
?>

What is going wrong?

Member Avatar for iamthwee

From what I see browing is not a member function in a Class.

Therefore just call it searchbrowse()

instead of:

$browsing->searchbrowse()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.