Req #66876 [Nab]: missing data on file read
Edit report at https://bugs.php.net/bug.php?id=66876&edit=1
ID: 66876
User updated by: rennie at bdevel dot co dot uk
Reported by: rennie at bdevel dot co dot uk
Summary: missing data on file read
Status: Not a bug
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Ubuntu
PHP Version: 5.5.10
Block user comment: N
Private report: N
New Comment:
Thank you for the "or |" mix up. (I'm an X macro 64 programmer)
This is the strangest thing ever. I renamed the file from php to txt, removed the php header lines
and all works as expected, so you were right; the problem WAS in the data, but I still think it
strange, if not exactly a bug!
Previous Comments:
------------------------------------------------------------------------
[2014-03-10 18:43:57] requinix@php.net
Works for me.
a href="ppl/a/b/cae94b82d133a7c8fba.php">Charles Edward Steelspan
class="grampsid"> [I2780]/span>/a>
Output $string[$k] before and after the replacement and then look at the *HTML source of the page*
to see what really happened. I'm closing this NaB because I can practically guarantee you that
there is a problem with your code or your input and not with PHP itself.
And by the way, "or" is a boolean operator. You should be using the bitwise |.
http://www.php.net/manual/en/language.operators.php
------------------------------------------------------------------------
[2014-03-10 18:22:08] rennie at bdevel dot co dot uk
<?php
echo "Starting Individuals - Created a new IdToGramps<br>";
$tfile = trim($_SERVER['DOCUMENT_ROOT'])."/Bowe/GrampsWeb/individuals.php";
//$fo = fopen ($tfile, "r") or die("No individuals.php"); // for fget etc.
$count = 0;
$string = file($tfile, FILE_IGNORE_NEW_LINES or FILE_SKIP_EMPTY_LINES);
echo "Array is: ".sizeof($string)."<br>";
$k = 0;
do {
$string[$k] = str_replace("<","",$string[$k]);
echo "Number ".$k." String ".$string[$k]."<br>";
$k++;
}while($k<200);
?>
individuals.php is what I call a "flat file" this is sufficient to demonstrate the
problem. (The actual file holds details of about 9000 people.)
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en-GB" lang="en-GB">
<head lang="en-GB">
<title>Bowe Family Big Tree - Individuals</title>
<meta charset="UTF-8" />
<meta name ="viewport" content="width=device-width, initial-scale=1.0,
maximum-scale=1.0, user-scalable=1" />
<meta name ="apple-mobile-web-app-capable" content="yes" />
<meta name="generator" content="Gramps 3.4.4-1 http://gramps-project.org/" />
<meta name="author" content="Rennie Bowe" />
<link href="images/favicon2.ico" type="image/x-icon" rel="shortcut
icon" />
<link media="screen" href="css/narrative-screen.css"
rel="stylesheet" type="text/css" />
<link media="print" href="css/narrative-print.css"
rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
<h1 id="SiteTitle">Bowe Family Big Tree</h1>
</div>
<div class="wrapper" role="navigation" id="nav">
<div class="container">
<ul class="menu" id="dropmenu">
<li class = "CurrentSection"><a href="individuals.php"
title="Individuals">Individuals</a></li>
<li><a href="index.php"
title="Surnames">Surnames</a></li>
<li><a href="families.php"
title="Families">Families</a></li>
<li><a href="places.php"
title="Places">Places</a></li>
<li><a href="sources.php"
title="Sources">Sources</a></li>
</ul>
</div>
</div>
<div class="content" id="Individuals">
<p id="description">
This page contains an index of all the individuals in the database, sorted by their last names.
Selecting the person’s name will take you to that person’s individual page.
</p>
<div id="alphanav">
<ul>
<li><a href="#A" title="Alphabet Menu: A">A</a></li>
<li><a href="#B" title="Alphabet Menu: B">B</a></li>
<li><a href="#C" title="Alphabet Menu: C">C</a></li>
<li><a href="#D" title="Alphabet Menu: D">D</a></li>
<li><a href="#E" title="Alphabet Menu: E">E</a></li>
<li><a href="#F" title="Alphabet Menu: F">F</a></li>
<li><a href="#G" title="Alphabet Menu: G">G</a></li>
<li><a href="#H" title="Alphabet Menu: H">H</a></li>
<li><a href="#I" title="Alphabet Menu: I">I</a></li>
<li><a href="#J" title="Alphabet Menu: J">J</a></li>
<li><a href="#K" title="Alphabet Menu: K">K</a></li>
<li><a href="#L" title="Alphabet Menu: L">L</a></li>
<li><a href="#M" title="Alphabet Menu: M">M</a></li>
<li><a href="#N" title="Alphabet Menu: N">N</a></li>
<li><a href="#O" title="Alphabet Menu: O">O</a></li>
<li><a href="#P" title="Alphabet Menu: P">P</a></li>
<li><a href="#Q" title="Alphabet Menu: Q">Q</a></li>
<li><a href="#R" title="Alphabet Menu: R">R</a></li>
<li><a href="#S" title="Alphabet Menu: S">S</a></li>
<li><a href="#T" title="Alphabet Menu: T">T</a></li>
<li><a href="#U" title="Alphabet Menu: U">U</a></li>
<li><a href="#V" title="Alphabet Menu: V">V</a></li>
<li><a href="#W" title="Alphabet Menu: W">W</a></li>
<li><a href="#Y" title="Alphabet Menu: Y">Y</a></li>
<li><a href="#Z" title="Alphabet Menu: Z">Z</a></li>
</ul>
</div>
<table class="infolist primobjlist IndividualList">
<thead>
<tr>
<th class="ColumnSurname">Surname</th>
<th class="ColumnName">Given Name</th>
<th class="ColumnDate">Birth</th>
<th class="ColumnDate">Death</th>
<th class="ColumnPartner">Partner</th>
<th class="ColumnParents">Parents</th>
</tr>
</thead>
<tbody>
<tr class = "BeginSurname">
<td class="ColumnSurname"><a id="A" name="A"
title="Surnames Abbott beginning with letter A">Abbott</a></td>
<td class="ColumnName">
<a href="ppl/a/b/cae94b82d133a7c8fba.php">Charles Edward Steel<span
class="grampsid"> [I2780]</span></a>
</td>
<td class="ColumnBirth">about Nov 1869</td>
<td class="ColumnDeath">about Aug 1943</td>
------------------------------------------------------------------------
[2014-03-10 16:26:19] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
The exact contents of the input file could make all the difference. And protip: when debugging HTML
you need to be looking at the source of the page, not the output you see rendered by your browser.
------------------------------------------------------------------------
[2014-03-10 11:51:58] rennie at bdevel dot co dot uk
Work around: Use Dreamweaver to remove offending characters leaving
<a href="ppl/d/a/cae94ba15305f07a3ad.php">Cunnigham, Georgina Gladys
[I7532]</span></a>
Now works, but it took 2.5 hrs to replace all 9000 records!
------------------------------------------------------------------------
[2014-03-10 10:26:48] rennie at bdevel dot co dot uk
Description:
------------
code snipit
$string = file($tfile, FILE_IGNORE_NEW_LINES or FILE_SKIP_EMPTY_LINES);
echo "Array is: ".sizeof($string)."<br>";
$k = 0;
do {
$string[$k] = str_replace("<","",$string[$k]);
echo "Number ".$k." String ".$string[$k]."<br>";
$k++;
}while($k<200);
line(s) that fails is (cut and paste using Dreamweaver):
<a href="ppl/a/b/cae94b82d133a7c8fba.php">Charles Edward Steel<span
class="grampsid"> [I2780]</span></a>
All data past <span class="grampsid"> is dropped until the /a. This happens with
fget fgets et. etc. 100% reproduced. There is a similar bug report but the "fix" given
does not work for me!
Expected result:
----------------
Number 50 String a href="ppl/a/b/cae94b82d133a7c8fba.php">Charles Edward Steel span
class="grampsid"> [I2780] /span> /a>
Actual result:
--------------
Number 50 String a href="ppl/a/b/cae94b82d133a7c8fba.php">Charles Edward Steel/a>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66876&edit=1
Thread (6 messages)