-1

Here is the code:

while($i != $unisize){
                $sql2 = "SELECT * FROM suscritos WHERE sector='$uni[$i]' AND oficio='$oficio'";
                $req2 = mysql_query($sql2);
                $co2 = mysql_num_rows($req2);
                        if($co2 == 0){
                            die("Unable to find near you"); 
                        }else{
                            while ($row2 = mysql_fetch_array($req2){
                            array_push($idarray, $row2['id']);                              
                            }
                        }
                $i++;
        }

This is the error: Parse error: syntax error, unexpected '{'

All the other variables have been declared before.

Thanks.

Daniel
  • 63
  • 1
  • 6
  • Some online validator can help you to check where the error is (ideone of php formatter). Although the browser should provide you enough information. Next time, use them before asking here. – AkiEru Mar 30 '15 at 03:32
  • Sorry, im starting... – Daniel Mar 30 '15 at 04:33

4 Answers4

3

You forgot a closing parenthesis here:

while ($row2 = mysql_fetch_array($req2){

where it should be:

while ($row2 = mysql_fetch_array($req2)){

On the side note, use mysqli_* prepared statement rather than the deprecated mysql_* to prevent SQL injections.

Community
  • 1
  • 1
Logan Wayne
  • 6,001
  • 16
  • 31
  • 49
0

As indicated by the error message, there is a syntax error in your code. In order to solve this error, please replace this line:

while ($row2 = mysql_fetch_array($req2) {

By the following:

while ($row2 = mysql_fetch_array($req2)){

You were missing a closing parenthesis ) in your while clause.

Joël Salamin
  • 3,538
  • 3
  • 22
  • 33
Ayyanar G
  • 1,545
  • 1
  • 11
  • 24
0

You missed to close the while () here:
while ($row2 = mysql_fetch_array($req2)<<<<<<

DevManX
  • 476
  • 3
  • 14
0

Close while loop

while ($row2 = mysql_fetch_array($req2)
4EACH
  • 2,132
  • 4
  • 20
  • 28