By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,642 Members | 1,674 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,642 IT Pros & Developers. It's quick & easy.

Flat File DB, PHP, and charaters

P: 2
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,
Jan 31 '07 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 1,584

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.
Feb 1 '07 #2

Expert 2.5K+
P: 4,258
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("These are special chars &{}";
header("Location: x.php?var=$myvar");

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

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

Ronald :cool:
Feb 1 '07 #3

P: 2
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:
$fp = fopen('testdb.txt','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?field2=".$field2."\">".$field2."</a><br>\n";

Detail Page:
$item2 = $_REQUEST[field2];

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

echo "
<p>".$field1."<br>".$field2."<br>".$field3."<br><b r>".$field4."</p>\n";
// END Details Container
Feb 1 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.