SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast Hanabi's Avatar
    Join Date
    Mar 2002
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Complex queries with PHP and MySQL

    Hi,
    I try to use a PHP program which is supposed to allow a user to select different criteria to search a database.
    the two criteria that can be selected are the level of confidence and experience.
    The field searched in the database are word and excel.
    I always get the following error message:
    PARSE ERROR...on line 36

    I've spent days trying to find out what was wrong. Can somebody help me?

    <?
    // connect to database
    mysql_connect ("localhost", "database", "password");

    // Check for selected criteria
    $searchFor = "";
    if($confidence && $experience){
    $searchFor = 'conf_word = .$confidence. and conf_excel = .$experience.';
    }
    elseif($confidence && !$experience){
    $searchFor = 'conf_word =' .$confidence;
    }
    elseif($experience && !$confidence){
    $searchFor = 'conf_excel =' .$experience;
    }


    // send request
    $result = mysql_db_query ('database', 'SELECT * FROM table WHERE' .$searchFor);

    // Print results
    $i=0;
    while ($row = mysql_fetch_row($result)) {
    $fields = mysql_num_fields($result);

    for( $i = 0; $i < $fields; $i++) {
    print "$row[$i]";
    }
    }

    $i++;
    $name= $row[l_name];
    $email= $row[f_name];
    //This is line 36 (empty!)
    echo "l_name$i=$name&f_name$i=$email";


    //echo "&totalResults=$i&loaded=true";
    ?>
    Thanks for your time.

    Hanabi.

  2. #2
    SitePoint Wizard silver trophy redemption's Avatar
    Join Date
    Sep 2001
    Location
    Singapore
    Posts
    5,269
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Complex queries with PHP and MySQL

    PHP Code:
    if($confidence && $experience){
      
    $searchFor 'conf_word = .$confidence. and conf_excel = .$experience.';

    you problem could be that you messed up your quotes in this line.... it should be:
    PHP Code:
    if($confidence && $experience){
      
    $searchFor 'conf_word = '.$confidence.' and conf_excel = '.$experience.';



Bookmarks

Posting Permissions

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