Need help with if statement to display correctly in html table

Discussion in 'PHP' started by scriptglue, Oct 1, 2008.

  1. #1
    I having a problem getting the $display to display between the <td> tags. This is what the html source looks like when the php code below is executed
    <table>
    php.com TAKEN<tr>
    <td></td>
    </tr>
    </table>


    IT SHOULD DISPLAY LIKE THIS
    <table>
    <tr>
    <td>php.com TAKEN</td>
    </tr>
    </table>

    What am I doing wrong? Please help.


    
    <?php
        function checkDomain($domain,$server,$findText){
            // Open a socket connection to the whois server
            $con = fsockopen($server, 43);
            if (!$con) return false;
            
            // Send the requested doman name
            fputs($con, $domain."\r\n");
            
            // Read and store the server response
            $response = ' :';
            while(!feof($con)) {
                $response .= fgets($con,128); 
            }
            
            // Close the connection
            fclose($con);
            
            // Check the response stream whether the domain is available
            if (strpos($response, $findText)){
                return true;
            }
            else {
                return false;   
            }
        }
        
        function showDomainResult($domain,$server,$findText){
           if (checkDomain($domain,$server,$findText)){
             echo $domain." AVAILABLE";
           }
           echo $domain." TAKEN";
        }
    ?>
    
    <table>
    <?php    
    $display = '<tr>
    <td>'.showDomainResult("php.com",'whois.crsnic.net','No match for').'</td>
    </tr>';
    echo $display;
    ?>
    </table>
    
    
    PHP:

     
    scriptglue, Oct 1, 2008 IP
  2. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #2
    i cant seems to find anything wrong with the script =x
     
    ads2help, Oct 1, 2008 IP
  3. mallorcahp

    mallorcahp Peon

    Messages:
    141
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Try this :

    I think the function showDomainResult is outputting rather than returning the result ...
     
    mallorcahp, Oct 1, 2008 IP
  4. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Oh yeah, tested using return and it works. great =)
     
    ads2help, Oct 1, 2008 IP
  5. scriptglue

    scriptglue Banned

    Messages:
    170
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for your help, that worked
     
    scriptglue, Oct 1, 2008 IP