Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

.

function is_valid_isbn($isbn)
{
  $isbn_length  =  strlen($isbn);
  $isbn_sum     = 0;
  echo "this is the length :";
  echo $isbn_length;
  for($i=0; $i < $isbn_length; $i++) { $total += (substr($isbn, $i, 1) * (11-($i+1))); }
 return true;
 }

When i run this function i am getting following error can some one help me where is the err ??

Here is the error message
Parse error: parse error, expecting `';'' in C:\xampp\htdocs\gbload\application\libraries\Isbnconv.php on line 47

share|improve this question
1  
I'm assuming the <br> tags are not in your actual code? – James Skidmore Aug 14 '10 at 19:33
    
which one is line 47? – rabidmachine9 Aug 14 '10 at 19:34
    
yeah there are no br tags in the code and line 47 is for($i=0; $i < $isbn_length; $i++) { $total += (substr($isbn, $i, 1) * (11-($i+1))) – Sandeep Reddy Aug 14 '10 at 19:35
1  
Should there be a < sign on line 47 between the $i and $isbn_length variables? – Matt Huggins Aug 14 '10 at 19:39
    
yeah there was < symbol in the condition statment of the for loop it got missed while i have copy pasted the code here. – Sandeep Reddy Aug 14 '10 at 19:44

Next time, pls tell us where is the line 47. See the fixed code below:

function is_valid_isbn($isbn)
{


  $isbn_length  =  strlen($isbn); //no br here
  $isbn_sum     = 0;//no br here
  echo "this is the length :"; //same 
  echo $isbn_length;//same
  for($i=0; $i < $isbn_length; $i++) //wrong here, missing the operator <
  { 
          $total += substr($isbn, $i, 1) * (11-$i+1); //too many ( )
  }//no br here
  return true;
}
share|improve this answer
    
sorry that was my mistake while copy pasting.. my code was inded having the lessthan condition in the for loop for($i=0; $i < $isbn_length; $i++) { $total += (substr($isbn, $i, 1) * (11-($i+1))); } – Sandeep Reddy Aug 14 '10 at 19:40
    
So it must be wrong somewhere else? – Bang Dao Aug 14 '10 at 19:42
    
no the Error msg says there is some problem in the for loop line which is line numbe 47.. – Sandeep Reddy Aug 14 '10 at 19:43
    
There're no parse error on my php-apache-local, then let try another way.So pls do the following things: 1. check your file encoding, is that utf-8 or something like that. 2. check if the current file is Isbnconv.php 3.copy 100% exactly that file's content to here. After that, we can try to find what is the cause again. – Bang Dao Aug 14 '10 at 19:50
for($i=0; $i$isbn_length; $i++) 

maybe it should be: for($i=0; $i==$isbn_length; $i++) or something like that...

share|improve this answer
    
sorry that was my mistake while copy pasting the code it was having a lessthan symbol there for($i=0; $i < $isbn_length; $i++) { $total += (substr($isbn, $i, 1) * (11-($i+1))); } – Sandeep Reddy Aug 14 '10 at 19:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.