Flat File DB, PHP, and charaters

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • artdezine4
    New Member
    • Jan 2007
    • 2

    Flat File DB, PHP, and charaters

    Please forgive me for my newbie-ness.

    I am one week into PHP and am having some minor issues.

    1. Using a flat file db, is it not possible to pass the "&" sign and quotations to another page. I am not using a form and couldn't figure out how to pass info using POST.

    porn site link removed - moderator

    2. Is there a way to pass one field to the next page and then retrieve all fields on the next page. (i.e. click on e001 in the gallery, then the detail page would list all the fields.)

    Thanks so much,
    Art
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    Hi,

    why don't you submit the code snippets that with you.
    these guys not going to give you the completed coding.
    at least submit your html pages or flat files with u.
    cant understand anything from ur post.

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      1. Use the php function urlencode() to encode parameter strings. AT the receiving side you can then use the urldecode() to get the original string back. Example:[php]$myvar = urlencode("Thes e are special chars &{}";
      header("Locatio n: x.php?var=$myva r");

      at the receiving side:
      $var = urldecode($_GET['var']);
      [/php]

      2. I don't understand your question. When you send 1 value, you receive 1 value.

      Ronald :cool:

      Comment

      • artdezine4
        New Member
        • Jan 2007
        • 2

        #4
        Ooops, ok, sorry.

        I simplified my coding to be the following:

        db file (testdb.txt):
        Stuff in Field 1|n001|More Stuff in 3|Even more in four
        Rec 2 in Field 1|n002|More Rec 2 Stuff in 3|Even more Rec 2 in four




        Listing page:
        [PHP]<?php
        $fp = fopen('testdb.t xt','r');
        if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;}

        while (!feof($fp)) {
        $line = fgets($fp, 1024); //use 2048 if very long lines
        list ($field1, $field2, $field3, $field4) = split ('\|', $line);
        echo "
        <a href =\"detail.php?f ield2=".$field2 ."\">".$field2. "</a><br>\n";
        $fp++;
        }
        fclose($fp);
        ?>[/PHP]




        Detail Page:
        [PHP]<?php
        $item2 = $_REQUEST[field2];

        $fp = fopen('testdb.t xt','r');
        if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;}
        echo $item2;

        echo "
        <p>".$field1."< br>".$field2."< br>".$field3."< br><br>".$field 4."</p>\n";
        // END Details Container
        fclose($fp);
        ?>
        [/PHP]

        Comment

        Working...