Results 1 to 9 of 9

Thread: cache issue ? idk pls help !

  1. #1
    Join Date
    Apr 2005
    Posts
    54
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Exclamation cache issue ? idk pls help !



    Hi

    i have this code that reads a txt file and pop ups a pdf if a part number is associated with it. if a part number is enter and it is not in the txt file a warning shows. my problem is that the warning stays on the page even if you refresh it...is there a way to clear it ?

    Heres the code:

    <form name="frmSearch" method="post" action="<?php echo $PHP_SELF;?>" onSubmit="return verifyForm(this);">




    <td align="center" background="images/Website_13a.jpg">


    <input type="hidden" name="action" value="search">

    <?
    // user sets the file name here.
    $data_file = "testdb2.txt";
    $prt = $_POST['part_num'];
    $dataset = file("testdb2.txt");
    $pdfPath = "";
    if( $prt != "" && $_POST['action']=="search" )
    {
    for( $i = 0; $i < count( $dataset ); $i++ ){
    // extract the record key and compare
    $dataset[$i] = trim( $dataset[$i] );
    $record_key = strtok( $dataset[$i], " " );
    $record_key = trim( $record_key );
    if( strcmp( $record_key, $prt ) == 0 ) {
    $stringArray = explode( " ", $dataset[$i], 2 );
    $pdfPath = trim( $stringArray[1] );
    ?>
    <script language="JavaScript" type="text/javascript">
    window.open('<?echo($pdfPath);?>');
    </script>
    <?
    break;
    } // end of if
    } // end of for
    } // end of outermost if

    // if it gets to this point, the record was not found in the file.
    ?>

    <input name="part_num" type="text" id="part_num" size="12"></td>
    <td width="32"><input type="image" src="images/Website_14.jpg" name="Submit" value="Search"></td>
    <!--displayin error -->

    <font color="red" style="font-family:Arial, Helvetica, sans-serif" size="-1">

    <?
    $error_msg = "";
    if( $pdfPath == "" ){
    $error_msg = "Warning: No Record was found associated to Part Number $prt";
    }
    echo( $error_msg );

    ?>

    </font>

    <!--displayin error end -->

    </form>

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    PHP Code:
    <?
    $error_msg 
    "";
    if( 
    $pdfPath == "" ){
    $error_msg "Warning: No Record was found associated to Part Number $prt";
    }
    echo( 
    $error_msg );

    ?>
    to

    PHP Code:
    <? php
    if( $pdfPath == "" ){
    $error_msg "Warning: No Record was found associated to Part Number $prt";
    }
    else {
    $error_msg "";
    }
    echo( 
    $error_msg );

    ?>
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Apr 2005
    Posts
    54
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    hi

    i just tried it and no luck

    the message "Warning: No Record was found associated to Part Number 32445566" stays on page even after i refresh the page....

  4. #4
    Join Date
    Apr 2005
    Posts
    54
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    i guess what i need is the error message to display once

    but once u go to another page or refresh it , the error message should be gone from page

    can that be done?

  5. #5
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    I should have looked better, once you trigger the error message, it will be there, then when it comes back to the page the error message is looking for the $pdfPath, which at the top of your code you are declairing as:

    PHP Code:
    $pdfPath ""
    One option is to give it a default value, which upon search is removed and replaced with the array, or replaced with nothing ("") which will then trigger the error message again.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  6. #6
    Join Date
    Apr 2005
    Posts
    54
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    I knew it was something wrong with the way i wrote it

    im just a beginner w the php stuff

    how would you change it?
    i guess i am asking you to improve what i have

    thanks

  7. #7
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Not sure. I won't be much help here. I would need to see the whole form and everything with it. Others around here will be able to help without looking I am sure.

    One thing you can try is to make the top $pdfPath = "Path"; instead of ""

    Your script should replace "Path" with the array when needed, but the default won't be "" anymore.

    Other than that I really don't know.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  8. #8
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    if you refresh the browser then you are just sending the same data, so the warning/error message should stay there, if new data is submitted and you are still getting this problem well then thats a matter of the default value as blizzard stated, however you do declare the error to be nothing before output is given, so I am going to lean into saying that you are just refreshing the same data.

    try to submit new data ?

  9. #9
    Join Date
    Apr 2005
    Posts
    54
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    when i submit new data error goes away
    can error go away when refreshing page?

    now.... if i go to another page that has the same form, the error keeps showing
    is there a way to fix that?

    plssss helppppppppppp

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
  •