Current location: Hot Scripts Forums » Programming Languages » PHP » unpack() problem


unpack() problem

Reply
  #1 (permalink)  
Old 12-15-08, 03:05 AM
firestar firestar is offline
Newbie Coder
 
Join Date: Sep 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
unpack() problem

I am having problem with my search engine. It seems to work fine
in PHP 4 but not in PHP5. The error was:

Warning: unpack() [function.unpack]: Type N: not enough input, need 4, have 1 in /var/www/vhosts/newsweekshowcase.com/httpdocs/newsweekshowcase/site-common-files/index-template-b(59) : eval()'d code on line 174
No fread2


Below are some of the codes:
PHP Code:

for ($j=0$j<count($query_arr); $j++) {
    
$query $query_arr[$j];
    
$allres[$j] = array();

    if (
$INDEXING_SCHEME == 1) {
        
$substring_length strlen($query);
    } else {
        
$substring_length 4;
    }
    
$hash_value abs(hashnew(substr($query,0,$substring_length)) &#37; $HASHSIZE);
    
    
    
    
fseek($fp_HASH,$hash_value*4,0);
    
$dum fread($fp_HASH,4) or die("No fread");
    
$dum unpack("Ndum"$dum);
    
fseek($fp_HASHWORDS,$dum['dum'],0);
    
$dum fread($fp_HASHWORDS,4);
    
$dum1 unpack("Ndum"$dum);
    
    
    
    for (
$i=0$i<$dum1['dum']; $i++) {
        
$dum fread($fp_HASHWORDS,8) or die("No fread2"); 
Why this error appear?Please help!!!

Last edited by Nico; 12-15-08 at 03:12 AM. Reason: Wrappers.
Reply With Quote
  #2 (permalink)  
Old 12-15-08, 04:30 PM
DAL's Avatar
DAL DAL is offline
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
Maybe it has something to do with this;

Quote:
Caution

Note that PHP internally stores integral values as signed. If you unpack a large unsigned long and it is of the same size as PHP internally stored values the result will be a negative number even though unsigned unpacking was specified.
quoted from php.net

I see the error for the last "No fread2" was outputted and the base for the fread has changed... maybe it's got something to do with that. (guess) check out the comments as others have wrote functions to rewrite some of these unsigned to signed etc...
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Reply With Quote
  #3 (permalink)  
Old 12-19-08, 02:25 AM
firestar firestar is offline
Newbie Coder
 
Join Date: Sep 2008
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
any link that got sample codes?
Reply With Quote
  #4 (permalink)  
Old 12-19-08, 11:21 AM
DAL's Avatar
DAL DAL is offline
Code Master
 
Join Date: Jun 2003
Location: North East England/UK
Posts: 874
Thanks: 0
Thanked 0 Times in 0 Posts
What appart from the one I provided?
__________________
"once upon a midnight dreary, while i pron surfed, weak and weary, over many a strange and spurious site of 'hot xxx galore'. While i clicked my fav'rite bookmark, suddenly there came a warning, and my heart was filled with mourning, mourning for my dear amour," 'Tis not possible!", i muttered, "give me back my free hardcore!" quoth the server, 404."
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pls help website problem! iangarrinud CSS 1 01-03-08 01:48 PM
login, roles problem dbrook007 ASP.NET 10 11-10-06 03:42 PM
Form Display Problem neevrap02 Visual Basic 1 09-05-06 05:18 AM
Count problem kasic ASP.NET 1 10-20-04 12:23 AM
Asp and Microsoft Access 2002 problem gop373 ASP 2 10-06-04 09:13 AM


All times are GMT -5. The time now is 08:25 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.