SunQuest
 
           PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old June 1st, 2004, 06:50 AM
bala_kumar2k4 bala_kumar2k4 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 12 bala_kumar2k4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation passing file contents as variable

Hi ,I have a page with variable that contains the contents of a Text file and now i want to pass that vairable to another page .Here normal variables are passed but the variable that contains the text file contents are not passed.

This is the code i have written,please refer and find the fault .
<?

$a=array("bala","uday","prabha");
echo"Array contents are :"."<br>";

for($i=0;$i<count($a);$i++)
{
echo"<b>$a[$i]</b><br>";
}

?>
<?

$fs=fopen('project_text.txt',"r");
$s=fread($fs,filesize('project_text.txt'));


echo'<body onload=parent.comment.location="comment.php?testc='.$s.'"';


?>


Reply With Quote
  #2  
Old June 1st, 2004, 07:05 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
You can only pass 1024 characters in the query string. If your text file is going to contain more than that, you'll encounter problems. Also, what's "parent.comment.location"? I've never seen anything quite like that before.

The best way to pass text like this will be either to pass the filename to the next script and let that script open the file or to stick it in a hidden field and POST it to the next page.
__________________
Please don't PM me asking for solutions outside the scope of a thread.
Keeping all responses in a thread stands to help others who come along later,
which is after all what this forum's all about.

Reply With Quote
  #3  
Old June 1st, 2004, 11:07 PM
bala_kumar2k4 bala_kumar2k4 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 12 bala_kumar2k4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Sir,actually my task is having three frames.In the left frame,I have a select box that displays the dir folders and when clicking the select box folders,it will dynamically displays the files retreived from the database.In the other 2 frames I want to display the output and the source code respectively.
Here everything is perfect,but the only problem is how to display the source code corresponding to each files.
can u help me...

Reply With Quote
  #4  
Old June 2nd, 2004, 07:37 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Seems like you've got it just about right. All you have to do is have the page loaded in the frame take a database ID as a parameter. The page then loads in your frame and queries the database (or the filesystem) to load the necessary text. It seems that you're trying to pass the text itself, when it's better to pass a reference to the text and to have the newly loaded page load the text.

Reply With Quote
  #5  
Old June 2nd, 2004, 11:19 PM
bala_kumar2k4 bala_kumar2k4 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 12 bala_kumar2k4 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Arrow

Thank u sir,But I'm new to PHP.So,please can u show me an example for using database ID and how to pass and display it...

Reply With Quote
  #6  
Old June 3rd, 2004, 07:03 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
That's pretty basic stuff. If you're not familiar with such basics, you need to find a book or tutorial on PHP fundamentals. Essentially, I'm suggesting that you pass either a database or a filename in the query string (http://www.url.com?id=00001, for example) and then use that id in the resulting file to query the database or open the given text file. This is something you'll do over and over again in PHP development, so understanding it now is crucial. There are probably tutorials on this site that will provide general information that'll help you out. I'm afraid I don't have time to rewrite what many others have already written.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > passing file contents as variable


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway