SunQuest
 
           General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

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:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old February 11th, 2003, 06:17 AM
martincrumlish martincrumlish is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Ireland
Posts: 9 martincrumlish User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
please help: tricky file generation problem

Hi,

I have a problem with a HTML generator script I am writing. Basically, I run a PHP script in a while loop. The output of this is stored in a file and then using PHP's file functions, this file is written into a HTML file.

The code in my PHP file is fine but there is a problem with the generated HTML.
Firstly, I am passing a value and using ereg_replace to replace the word -track- in the PHP file with this value. This value is a word and it can be of variable length. Now, when say I run through a loop of 10 names, each of different lengths. When I open the generated HTML files I am seeing parse errors that aren't actually correct.

ie - This error is coded into the generated HTML page because it occurred when the PHP script was being run:
PHP Code:
 Fatal errorCall to undefined function: ifx_fet() in 
c
:program filesnusphereapachensdocshorseracingresultsre  buildresultscache.php on line 104 


Obviously, ifx_fet() isnt a function. The actual line 104 code in resultscache.php is this:
PHP Code:
while($row1 ifx_fetch_row($result1)){ 


This is an informix DB function and when I run resultscache.php in the browser and not through the generator script, there are no parse errors. Similarly, in one of the other generated HTML files there is this error:
PHP Code:
 Fatal errorCall to undefined function: ifx_fetch_row_row()

 
in c:program filesnusphereapachensdocshorseracingresultsre  buildresultscache.php on line 104 


The word that was passed to generate the first file was 13 characters long while the word for the 2nd file was 7 characters long. For some reason, the PHP seems to be getting messed up when it is read into my script.

I use the code below to read a txt file, replace the appropriate words, save it as resultscache.php, run resultscache.php and then save the HTML output of resultscache.php as a HTML file:

PHP Code:
 $tempfilename "tempindex.html";
$targetfilename 
"html/".$startyear."/".$startmonth."/".$startday."/".$track.$startdate.".html";

//put space back in track for DB query
$track ereg_replace("_"" "$track);
?>
<html>
<head>
<title>Generating HTML...</title>
</head>
<body>
<p>Generating <?= $targetfilename?>...</p>
<?php

//change the txt file into a PHP file that replaces placeholder text 
with the correct PHP generated Track name (generated from the 
query
)
$tempfile "resultscache.php";
$fp1 fopen($tempfile'w');
$fp fopen($filepath."resultscache.txt""w") or die("Couldn't open file"); 
$data fread($fpfilesize($fp)); 
$data .= fread($fp100000); 
$toreplace "-track-";
$replacewith $track;
$data ereg_replace($toreplace$replacewith$data);
$toreplace1 "-date-";
$replacewith1 $startdate;
$data ereg_replace($toreplace1$replacewith1$data);
$ok fwrite($fp1$data);
fclose($fp); 
//generate php file end

//unlink($tempfilename);

$dynpage fopen($srcurl'r');

if(!
$dynpage){
    echo(
"<p>Unable to load $srcurl. Static page "."update aborted!</p>");
    exit();
}

$htmldata fread($dynpage1024*1024);

fclose($dynpage);

$tempfile fopen($tempfilename'w');

if(!
$tempfile){
    echo (
"<p>Unable to open temporary file");
    exit();
}

fwrite($tempfile$htmldata);

fclose($tempfile);
$ok copy($tempfilename$targetfilename);

unlink($tempfilename); 


I am stumped with this and I have a dealdine hanging ove rmy head so any help is appreciated!

Thanks,
Martin

note: there is forward slashes in the rror output but vBulletin removes them.

Reply With Quote
  #2  
Old February 11th, 2003, 01:46 PM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 6
Other than getting that error in your file output, is the output correct? if so, just suppress the message using '@'...
__________________
~ Joe Penn

We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set?

Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you.




Reply With Quote
  #3  
Old February 11th, 2003, 02:29 PM
martincrumlish martincrumlish is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Ireland
Posts: 9 martincrumlish User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

The error means the database query doesnt produce an array of results to loop through making the page a mess so @ wouldnt work.

its a strange problem because it only happens in some files, I am guessing it might be something to do with how the file is being read and then the different lengths of variable name used to replace -track- could be throing it off somehow.

Anyone else got any ideas on this?

Thanks,
Martin

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > please help: tricky file generation problem


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 2 hosted by Hostway