CrazyEngineers
  • Creating Search Engine: MySQL Warning

    Updated: Oct 26, 2024
    Views: 1.5K
    hello,

    i am creating a search engine..

    and i am getting an error

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in c:\wamp\www\major project\search.php on line 22

    in the command written below

    sql_select_db ("music_park");

    $get= mysql_query("SELECT * from searchengine");
    while ($getrow= mysql_fetch_assoc($get))
    {

    //explode our search

    $search_explode = explode(" ", $search);

    foreach ($search_explode as $search_each)
    {
    //construct query

    $x++;
    if ($x==1)

    $construct .= "keywords LIKE '%$search_each%'";
    else
    $construct .= "OR keywords LIKE '%$search_each%'";

    }

    //echo out construct

    $construct = "SELECT * from searchengine WHERE '$construct'";
    $run = mysql_query ('$construct');
    $foundnum = mysql_num_rows('$run');

    if ($foundnum ==0)
    echo "no result found";
    else
    {
    echo "$foundnum result found! <p>";
    }
    }


    please somebody help me out to remove this error..

    thank you very much...!!!
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Manish Goyal

    MemberJan 3, 2011

    Re: warning message

    which database are you using for this?
    Are you sure? This action cannot be undone.
    Cancel
  • manojsinghrana

    MemberJan 3, 2011

    Re: warning message

    hello,
    if you are asking me the name of my database then it is music_park.

    and i am working on wampserver.
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberJan 3, 2011

    no i am asking are you using mysql or something else
    Are you sure? This action cannot be undone.
    Cancel
  • silverscorpion

    MemberJan 3, 2011

    Wamp server uses MySQL only..

    Well, I don't see mysql_connect function being used to connect to the database first.
    If you have used it in the code before, fine.

    Also, use mysql_select_db instead of sql_select_db. That seems to be the only mistake to me.. try it.

    You can also try printing the result of your query to know if the query is actually executed or not.
    After the mysql_query line, just include a line to print the variable get.

    $get = mysql_query("SELECT * from searchengine");
    echo $get;
    Now you'll know what is stored in the variable when you are running the while loop.
    Are you sure? This action cannot be undone.
    Cancel
  • manojsinghrana

    MemberJan 16, 2011

    yes i am using mysql.
    Are you sure? This action cannot be undone.
    Cancel
  • garima8905

    MemberOct 15, 2011

    sir, please help me to make a project in search engine in asp.net.
    Are you sure? This action cannot be undone.
    Cancel
  • garima8905

    MemberOct 15, 2011

    Re: warning message

    can you help me by guiding me how to make a search engine.?
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register