views:

40

answers:

2

.

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

+1  A: 

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;
}
Bang Dao
sorry that was my mistake while copy pasting..my code was inded having the lessthan condition in the for loopfor($i=0; $i < $isbn_length; $i++) { $total += (substr($isbn, $i, 1) * (11-($i+1))); }
Sandeep Reddy
So it must be wrong somewhere else?
Bang Dao
no the Error msg says there is some problem in the for loop line which is line numbe 47..
Sandeep Reddy
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
A: 
for($i=0; $i$isbn_length; $i++) 

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

rabidmachine9
sorry that was my mistake while copy pasting the code it was having a lessthan symbol therefor($i=0; $i < $isbn_length; $i++) { $total += (substr($isbn, $i, 1) * (11-($i+1))); }
Sandeep Reddy