search box

Discussion in 'PHP' started by majidk, Aug 3, 2009.

  1. #1
    Im trying to crack this serach box but it doesnt seem to work, when i click search, i get an empty screen. please help. This is my code:

    php.php

    <form action="search.php" method="post">
    <input type="text" name="query" id="query" size="40" value="" action="Search.php" columns="2" autocomplete="off" delay="1500">
    <input type="submit" value="Search">
    <input type="hidden" name="Search" value="1">
    </form>

    Search.php

    <html>
    <body>
    <?
    session_start();
    $myServer = '****';
    $myUser = '****';
    $myPass = '***';
    $myDB = '*****';
    $SpecRef = $_GET['query'];
    print ("$SpecRef");



    //connection to the database
    $dbhandle = mssql_connect($myServer, $myUser, $myPass)
    or die("Couldn't connect to SQL Server on $myServer");



    //select a database to work with
    $selected = mssql_select_db($myDB, $dbhandle)
    or die("Couldn't open database $myDB");
    //error message (not found message)begins
    $XX = "No Matches Found";
    //query details table begins
    $query = ("SELECT * FROM dbo.DesignControl WHERE Spec_Ref LIKE'$SpecRef%' ");
    // $query = ("SELECT * FROM dbo.DesignProcess");

    print(' is what you searched for:');


    //execute the SQL query and return records
    $result = mssql_query($query);

    $numRows = mssql_num_rows($result);
    echo "<h1>" . $numRows . " Record" . ($numRows == 1 ? "" : "s") . " Found </h1>";

    //display the results
    echo '<textarea>';
    while($row = mssql_fetch_array($result))
    {
    echo $row["Spec_Ref"] . "\n"; }
    echo '</textarea>';
    //close the connection
    mssql_close($dbhandle);
    //display the results
    while($row = mssql_fetch_array($result))
    {
    echo $row["Spec_Ref"] . "\n"; }
    echo '</textarea>';
    //close the connection
    mssql_close($dbhandle);
    //display the results
    while($row = mssql_fetch_array($result))
    {
    echo "<li>" . $row["Spec_Ref"] . "</li>";
    }
    //close the connection
    mssql_close($dbhandle);

    //textareaContent = "";

    //while ($row = @mysql_fetch_array($query))
    //{
    //$var1=$row["Player"];
    //$var2=$row["Avg"];
    //$var3=$row["HR"];
    //$var4=$row["RBI"];

    $textareaContent .= "Spec Ref: $var1 Avg: $var2 HR: $var3 RBI $var4 <br/>";
    //}

    //if (!isset($var1) || $var1=="") {
    //echo $XX;
    //}



    ?>
    </body>
    </html>
     
    majidk, Aug 3, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $SpecRef = $_GET['query'];
    PHP:
    should be $_POST['query'];
     
    premiumscripts, Aug 3, 2009 IP
  3. majidk

    majidk Guest

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    its still a blank page
     
    majidk, Aug 3, 2009 IP
  4. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try putting this at the top of the page if you do not have access to your error logs:

    
    <?php
    error_reporting(E_ALL);
    ini_set('display_errors', 1);
    ?>
    
    PHP:
    Also, change the "<?" to "<?php".
     
    premiumscripts, Aug 3, 2009 IP
  5. majidk

    majidk Guest

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If i created an FTP account for you, would you kind enought to do it me plz.
     
    majidk, Aug 3, 2009 IP
  6. majidk

    majidk Guest

    Messages:
    47
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Sorry

    Please ignore, wrong person
     
    majidk, Aug 3, 2009 IP