#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    india
    Posts
    0
    Rep Power
    0
    Hi,

    Here i have some problem on executing this code. The code is to list the records for the search string. Here I have send the program with the result. Please try to solve my problem.

    Codes:
    *****

    <?php
    $search = "philips sigg ds oio";
    $search=stripslashes($search);
    $searchtext = htmlentities($search);

    if($search!= "")
    {


    print "<table width="100%" border=0 cellpadding=2><tr><td
    align=right><a
    href="http://www.2skymall.com/Search_4.php3/"><font
    face=Arial,Helvetica
    size=1>New Search</font></a></td></tr></table>";


    $params = split( " ", $search);
    $InQuotedString = 0;
    $tokNum = 0;
    $tokens = array();
    echo $search;
    //Build Tokens. There's a gawd awful
    //way of doing this with a regex, but it's messy
    $tokens[$tokNum] = "";
    for($i=0; $i<count($params); $i++){
    if(!IsSet($tokens[$tokNum])){
    $tokens[$tokNum] = "";
    }
    $param = $params[$i];
    if(ereg( "^"", $param) &#0124; &#0124; ereg( "^[+-]"", $param)){
    $InQuotedString = 1;
    }
    if($InQuotedString == 1){
    $tokens[$tokNum] .= ereg_replace( """, "", $param) . " ";
    }
    else{
    $tokens[$tokNum++] = $param;
    }

    if(ereg( ""$", $param)){
    $InQuotedString = 0;
    $tokens[$tokNum] = chop($tokens[$tokNum]);
    echo "n<!--".$tokens[$tokNum]. "-->n";
    $tokNum++;
    }
    }
    echo "<p>";
    echo "*****<br>";
    if ($search!="")
    {
    $articleFields[] = "current_product.name";
    $articleFields[] = "current_product.short_description";


    $articleSQL = "Select DISTINCT
    current_product.name,current_product.short_description,
    current_product.unit_price,merchant.name
    from current_product , merchant WHERE merchant.user_id =
    current_product.merchant_id and (";


    for($i=0; $i<count($tokens); $i++){
    for($x=0; $x<count($articleFields); $x++){
    $token = ereg_replace( " $", "", $tokens[$i]);
    if(ereg( "^+", $token)){
    $token = ereg_replace( "^+", "", $token);
    $articleSQL .= "$articleFields[$x] like ('%$token%')";
    if($x<count($articleFields)-1){
    $articleSQL .= " OR ";
    }
    }
    elseif(ereg( "^-", $token)){
    $token = ereg_replace( "^-", "", $token);
    $articleSQL .= "$articleFields[$x] NOT like '%$token%'";
    if($x<count($articleFields)-1){
    $articleSQL .= " AND ";
    }
    }
    else{
    $articleSQL .= "$articleFields[$x] like '%$token%'";
    if($x<count($articleFields)-1){
    $articleSQL .= " OR ";
    }
    }
    }
    if($i<count($tokens)-1){
    $articleSQL .= ") AND (";
    }
    else{
    $articleSQL .= ")";
    }
    }


    echo "n<!--$articleSQL-->n";
    echo $articleSQL;

    }
    }

    $db = new DB_twoskymall;
    $db -> query($articleSQl);

    while ($db->next_record())
    {
    $name = $db ->f("current_product.name");
    $merchant_name = $db -> f("merchant.name");
    echo $name;
    echo $merchant;
    }
    ?>


    Result:
    ******
    Select DISTINCT current_product.name,current_product.short_description, current_product.unit_price,merchant.name from current_product , merchant WHERE merchant.user_id = current_product.merchant_id and (current_product.name like '%Philips%' OR current_product.short_description like '%Philips%') AND (current_product.name like '%Sigg%' OR current_product.short_description like '%Sigg%') AND (current_product.name like '%Ds%' OR current_product.short_description like '%Ds%') AND (current_product.name like '%Oio%' OR current_product.short_description like '%Oio%')
    Warning: OCIStmtExecute: ORA-24337: statement handle not prepared in db_oci8.inc on line 55

    ORA-24337: statement handle not prepared
    Query :""
    Warning: OCIFetchInto: OCI_INVALID_HANDLE in db_oci8.inc on line 71

    thanks ,
    saravanan
  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Please try to solve my problem.[/quote]

    Do I get a prize?

    I have a hard time helping people that want an answer now, because it's urgent, or that don't describe their problem enough. I don't like "it doesn't work..solve it for me."

    Everyone helping here is doing it out of the goodness of our heart, we're not getting paid. Okay..technically I'm at work while I'm doing this, so I'm getting paid now, but that's different.

    ---John Holmes...
  4. #3
  5. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    6
    Rep Power
    0
    Yeah, me to lol

    and ad some code tags arround it..
    its hard to read this way

    ------------------
    Greetings lewi
  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    I'm not too sure about the distinct statement in your sql query, but that wouldn't cause it to fail. You might not be getting the results you think, though...

    Are you sure the class is connecting to the database?

    ---John Holmes...
  8. #5
  9. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15
    saravanan,
    The sql statement looks ok..
    may be you need to use group it for getting desired result.


    <<
    DB_twoskymal
    >>

    Can you show that class file..something might be wrong in that..
    just test same sql query in sql prompt as well if you are using Oracle as back end.

    ------------------
    SR -
    webshiju.com
    www.jobxyz.com-IT Career Portal
    ezipindia.com--WebStudio


    "The fear of the LORD is the beginning of knowledge..."



    [This message has been edited by Shiju Rajan (edited November 02, 2000).]
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    india
    Posts
    0
    Rep Power
    0
    Hi,
    Thanks for your help, here I solved the problem. Actually the problem is to assign this statement to a variable name first before doing $Query(). It is working.

    thanks a lot,
    saravanan

Similar Threads

  1. c problem parsing code
    By mharvey in forum C Programming
    Replies: 4
    Last Post: February 11th, 2004, 01:02 PM
  2. functions slowing code
    By dave2k in forum PHP Development
    Replies: 5
    Last Post: February 7th, 2004, 07:40 PM
  3. Ensuring a file's code doesn't cause error in another.
    By Jason Doucette in forum C Programming
    Replies: 0
    Last Post: February 6th, 2004, 01:51 PM
  4. fread problem: doesn t compile php code
    By ghorghor2002 in forum PHP Development
    Replies: 2
    Last Post: February 3rd, 2004, 06:25 AM

IMN logo majestic logo threadwatch logo seochat tools logo