Results 1 to 5 of 5
  1. #1

    Exclamation Simply PHP Search Feature Problem

    Hello Guys,

    I am just a beginner in PHP. I am learning PHP from tutorials. I just tried to make a simple PHP search feature and connect it to my database to search the keywords from my database table. The tutorial is according to the PHP Version 4. But, my hosting server consist of PHP version 5. I think thats why it is not working. When I am trying to submit the keyword to search through an html form. It is showing me all the keywords from the table. But, it should match up with only that keyword, which i am entering in the html form.
    Kindly, help me out in this. Here is my PHP and HTML code.


    <form action="result.php" method="POST">

    <input type="text" name="name"><BR><BR>

    <input type="submit" value="Search">




    if (!$name) {

    echo "No Search Result";

    $db = mysql_connect("localhost", "sqlusername", "sqlpassword");
    mysql_select_db("sqldatabase", $db);

    $query = "SELECT, people.Height, people.Date
    FROM people WHERE name LIKE '%".$name."%'";

    $result = mysql_query($query);

    while ($record = mysql_fetch_assoc($result)) {

    while ( list($fieldname, $fieldvalue) = each($record)) {

    echo $fieldname . ": <b>" . $fieldvalue . "</b><br>";

    echo "<br>";



  2. #2
    Trying echoing out $query to see what $name is actually set too, that should give a good start

    You should also be using $_POST['name'] rather than $name

  3. #3
    Join Date
    May 2008
    Rutherford, NJ
    you're using register_globals, an old <=php4 feature that was incredibly insecure and is now deprecated as of php5. instead of $name, use $_POST['name']
    Database design and performance optimization, custom PHP scripts, and publicly available resources for developers!

  4. #4
    Join Date
    Feb 2005
    There are so many PHP tutorials on the net, including apparently this one, written by people with no clue what they were doing. If you continue with this one, the code won't work on most modern systems (as you've seen) and you'll be learning bad habits that will very likely get your website hacked in the future.

    Try to find more reputable tutorials. w3schools would be a good place to start.

    "Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them." - Laurence J. Peter

  5. #5
    It is better to write the db configuration in a seperate file and include it whenever required

    for example if your dbconfiguration file is in dbconnect.php
    PHP Code:
    $db mysql_connect("localhost""sqlusername""sqlpassword");
    then just use this statement in your code
    PHP Code:
    include "dbconnect.php"
    also For preventing sql injection always make use of mysql_real_escape_string() to pass variables in query
    Ezeelogin - The ultimate multiple server administration software.
    * Parallel shell * rm -rf protection * SSH logging * automated password changes * encrypted storage * - Delivering innovative web hosting solutions

Similar Threads

  1. Solar VPS, simply the end for my search.
    By DiegoMax in forum VPS Hosting
    Replies: 4
    Last Post: 03-06-2007, 07:32 PM
  2. search feature
    By cmtusa in forum Employment / Job Offers
    Replies: 3
    Last Post: 07-06-2005, 12:14 PM
  3. Search feature problem with hyphen
    By ACStudent in forum WHT Announcements, Feedback and Questions
    Replies: 3
    Last Post: 01-07-2005, 11:17 PM
  4. Bug in new search feature...
    By Coach in forum WHT Announcements, Feedback and Questions
    Replies: 5
    Last Post: 06-10-2003, 10:55 PM
  5. Simply Question about one WorldPay feature...
    By Milos in forum Running a Web Hosting Business
    Replies: 2
    Last Post: 04-29-2003, 05:21 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts