Use of undefined constant foundnum line 54

Discussion in 'Web Design and Development' started by balam, Dec 14, 2009.

  1. macrumors newbie

    Joined:
    Dec 14, 2009
    #1
    hi, can someone help me with this error pls. the error is Use of undefined constant in line 54. what is it thats not defined pls


    <?php

    include ('connect.php');

    error_reporting(E_ALL);
    ini_set('display_errors', '1');

    $submit = $_GET['submit'];
    $search = $_GET['search'];
    $x=0;
    $construct='';
    $foundnum="";

    if (!'submit')

    echo "you didnt submit a keyword.";

    else

    {

    if (strlen($search)<=2)

    echo "search term to short.";
    else
    {
    echo " You searched for <b>$search</b><hr size='1'>";

    //connect to our database

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


    foreach($search_exploded as $search_each)

    {

    // construct query

    $x++;
    if ($x==1)
    $construct .= " location LIKE '%$search_each%'";
    else
    $construct .= " OR rent LIKE '%$search_each%'";

    }

    // echo out construct

    $construct = "SELECT * FROM flats WHERE $construct";
    $run = mysql_query($construct);
    $foundnum = mysql_num_rows($run);

    if (foundnum==0)
    echo "No results found.";
    else
    {
    echo "$foundnum result found!<p>";

    while ($runrows = mysql_fetch_assoc($run))

    {

    // get data

    $select = $runrows['type'];
    $title = $runrows['title'];
    $location = $runrows['location'];


    echo "

    echo $title;
    echo <br>;
    echo $select;
    echo <br>;
    echo $rent;
    echo <br>;
    echo $location";

    }


    }
    }
    }


    ?>
     
  2. Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    Please use the PHP code block when posting code to improve readability.

    The error concerns this line,
    PHP:
    if (foundnum==0)
    See the problem? Missing $ in front of variable name.
     
  3. macrumors 68000

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #3
    Also...

    PHP:
    if (!'submit')
    Should be $submit
     

Share This Page