Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    57

    Unanswered: What's wrong in this script ? I can't set it up...

    Hi there!

    My problem is related to the conditional logic syntax.
    I know there's something wrong with the implementation of the curly braces for the if and else if statements but after numerous attempts, I gave up...

    Could you help me ?

    Many thanks in advance for your advices.

    PS: I have replaced the french strings with bla bla bla text...

    Code:
    <?php
    $liste = $_POST[ "secole" ];
    $table = "_annuaire";
    include 'key.php'; 
    mysql_connect( $host, $user, $pass) or die( "cannot connect " .mysql_error() ); 
    mysql_select_db( $db ) or die( "cannot select db ".mysql_error() ); 
    $result =mysql_query ("SELECT * FROM $table WHERE list LIKE '$liste' ORDER BY lastName, firstName, promo" ) or die ( "select error " .mysql_error () );
    if ( mysql_num_rows( $result ) > 0) {
    while ($row =mysql_fetch_array ($result ) ) { 
    $flashstr .= "<font color='#000099'>".$row ["lastName" ] "."</font>"." "."<font color='#663399'>".$row ["firstName" ]."</font>"." "."<font color='#0033CC'>".$row ["promo" ]."</font>".", "."<font color='#9966CC'>".$row ["region" ]."</font>"."<font color='#999999'>".$row ["gone" ]."</font>"."<br />";
    }
    if ( mysql_num_rows( $result ) < 2000) {
        print ("&erreur=bla bla bla"."&compte=".mysql_num_rows($result)."&listeecole=".urlencode($flashstr));
        }
        else 
        print ("&erreur=blo blo blo"."&compte=".mysql_num_rows($result))."&listeecole=blu blu blu");
        }
    }
    else
    print ("&erreur=ble ble ble"."&compte=0");
    ?>

  2. #2
    Join Date
    Jan 2004
    Location
    India
    Posts
    168
    There was some mistake in string concatination. I think you got confused with the quotes.
    Try with this code.
    PHP Code:
    <?php
    $liste 
    $_POST"secole" ];
    $table "_annuaire";
    include 
    'key.php'
    mysql_connect$host$user$pass) or die( "cannot connect " .mysql_error() ); 
    mysql_select_db$db ) or die( "cannot select db ".mysql_error() ); 
    $result =mysql_query ("SELECT * FROM $table WHERE list LIKE '$liste' ORDER BY lastName, firstName, promo" ) or die ( "select error " .mysql_error () );
    if ( 
    mysql_num_rows$result ) > 0
    {
        while (
    $row =mysql_fetch_array ($result ) ) 
        { 
            
    $flashstr .= "<font color='#000099'>".$row ['lastName' ]."</font>"." "."<font color='#663399'>".$row ["firstName" ]."</font>"." "."<font color='#0033CC'>".$row ["promo" ]."</font>".", "."<font color='#9966CC'>".$row ["region" ]."</font>"."<font color='#999999'>".$row ["gone" ]."</font>"."<br />";
        }
        if ( 
    mysql_num_rows$result ) < 2000
        {
        print (
    "&erreur=bla bla bla"."&compte=".mysql_num_rows($result)."&listeecole=".urlencode($flashstr));
        }
        else 
        {
        print (
    "&erreur=blo blo blo"."&compte=".mysql_num_rows($result))."&listeecole=blu blu blu");
        }
    }
    else
    print (
    "&erreur=ble ble ble"."&compte=0");
    ?>
    Regards
    Rajesh
    Freelance and Technology Consultant
    -------------------
    Dreams are for ever
    -------------------

  3. #3
    Join Date
    Apr 2004
    Location
    Canada
    Posts
    57
    Quote Originally Posted by rajesh_r_r
    There was some mistake in string concatination. I think you got confused with the quotes.
    Regards
    Rajesh
    Hi Rajesh!

    Silly of me! True.
    I gave it a try and... it works!

    Many thanks from Canada with my warmest regards.

Posting Permissions

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