tags:

views:

27

answers:

1

Erg. Starting in the past few days high tweet IDs (at least, it appears it's ID related, but I suppose it could be some recent change in the api returns) are breaking my code. At first I tried passing the ID as a string instead of an integer to this function, and I thought this worked, but in reality it was just the process of uploading the file from my end.

In short, a php script generates these function calls, and when it does so, they fail. If I download the php file the call is generated into, delete the server copy and re-upload the exact same file without changing it, it works fine. Does anyone know what could be causing this behavior?

Below is what I suspect to be the most important part of the individual files that are pulling the errors. Each of the files is named for a status ID (e.g. the below file is named 12058543656.php)

<?php
    require "singlePost.php";
    SinglePost(12058543656)
    ?>

Here's the code that writes the above files:

      $postFileName = $single_post_id.".php";
  if(!file_exists($postFileName)){
    $created_at_full = date("l, F jS, Y", strtotime($postRow[postdate])-(18000));
    $postFileHandle = fopen($postFileName, 'w+');
    fwrite($postFileHandle, '<html>
<head>
<title><?php $thisTITLE = "escarp | A brief poem or short story by '.$authorname.' on '.$created_at_full.'"; echo $thisTITLE;?></title><META NAME="Description" CONTENT="This brief poem or short story, by '.$authorname.', was published on '.$created_at_full.'">
<?php include("head.php");?>
To receive other poems or short stories like this one from <a href=http://twitter.com/escarp&gt;escarp&lt;/a&gt; on your cellphone, <a href=http://twitter.com/signup&gt;create&lt;/a&gt; and/or <a href=http://twitter.com/devices&gt;associate&lt;/a&gt; a Twitter account with your cellphone</a>, follow <a href=http://twitter.com/escarp&gt;us&lt;/a&gt;, and turn device updates on.
<pre><?php
    require "singlePost.php";
    SinglePost("'.$single_post_id.'")
    ?>
</div></div></pre><?php include("foot.php");?>
</body>
</html>');
    fclose($postFileHandle);}
  $postcounter++;
  }

I can post more if you don't see anything here, but there are several files involved and I'm trying to avoid dumping tons of irrelevant code.

Error:

Warning: include(head.php) [function.include]: failed to open stream: No such file or directory in /f2/escarp/public/12177797583.php on line 4 Warning: include(head.php) [function.include]: failed to open stream: No such file or directory in /f2/escarp/public/12177797583.php on line 4

Warning: include() [function.include]: Failed opening 'head.php' for inclusion (include_path='.:/nfsn/apps/php5/lib/php/:/nfsn/apps/php/lib/php/') in /f2/escarp/public/12177797583.php on line 4 To receive other poems or short stories like this one from escarp on your cellphone, create and/or associate a Twitter account with your cellphone, follow us, and turn device updates on.

Warning: require(singlePost.php) [function.require]: failed to open stream: No such file or directory in /f2/escarp/public/12177797583.php on line 7

Warning: require(singlePost.php) [function.require]: failed to open stream: No such file or directory in /f2/escarp/public/12177797583.php on line 7

Fatal error: require() [function.require]: Failed opening required 'singlePost.php' (include_path='.:/nfsn/apps/php5/lib/php/:/nfsn/apps/php/lib/php/') in /f2/escarp/public/12177797583.php on line 7

SinglePost()

<?php
function SinglePost($statusID) {
require "nicetime.php";
$db = sqlite_open("db.escarp");
$updates = sqlite_query($db, "SELECT * FROM posts WHERE postID = '$statusID'");
$row = sqlite_fetch_array($updates, SQLITE_ASSOC);
 $id = $row[authorID];
 $result = sqlite_query($db, "SELECT * FROM authors WHERE authorID = '$id'");
 $row5 = sqlite_fetch_array($result, SQLITE_ASSOC);
  $created_at_full = date("l, F jS, Y", strtotime($row[postdate])-(18000));
  $created_at = nicetime($row[postdate]);
  if($row5[url]==""){
  $authorurl = '';
  }
  else{
    /*I'm omitting a few pages of output code and associated regex*/
    return;
  }
?>
A: 

I doubt the high ID values are causing your problem (at least, not data-type related).

When PHP detects an integer overflow, it automatically converts the value to a float to prevent it. Therefore you can (somewhat) represent big numbers without any problems.


That being said, please make sure that the full path to the file do not exceed path length limitations of your file system and that the number of files in your folder doesn't exceed limitations either (for example, 65534 entries is the max for NTFS partitions).

Andrew Moore
Well, I don't know that I think the high ID is causing the problem IN php itself, but I suspect, yes, it's something to do with the file system, but I think the ID is causing the problem within that context. I don't think it's purely about the path length because I've got 10 other files with IDs past 10,000,000,000 that work fine. The first troublemaking ID was 12058543656.
escarp
@escarp: Maybe you simply have too many files in the same folder?
Andrew Moore