Parse error: syntax error, unexpected $end...

Discussion in 'PHP' started by gaspacho, Nov 17, 2007.

  1. #1
    Hi there I have issue with this php file down here. After i try to run it it shows Parse error: syntax error, unexpected $end in /var/www/show.php on line...

    it points to line with </html> ...

    I have browsed several topics and found that a } is missing but i dont know where. Thank you for help!

    <html>
    <head>
    <title></title>
    </head>
    <body>
    <?php
    $username="root";
    $password="Mixerstvo";

    switch ($value):

    case "linky":

    $database="zadanie";
    mysql_connect(localhost,$username,$password);
    @mysql_select_db($database) or die("Chyba pri pripajani na databazu");
    $query="SELECT * FROM linky";
    $result=mysql_query($query);
    $num=mysql_numrows($result);
    mysql_close();

    $i=0;

    while ($i < $num)
    {

    $meno=mysql_result($result,$i,"meno");
    $trasa=mysql_result($result,$i,"trasa");

    echo "<b>$meno | $trasa</b><br><hr><br>";

    $i++;
    }
    ?>
    </body>
    </html>
     
    gaspacho, Nov 17, 2007 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    witch statement you are using no { }


    switch ($i) {
    case "apple":
    echo "1";
    break;
    case "bar":
    echo "2";
    break;
    case "cake":
    echo "3";
    break;
    }
     
    kmap, Nov 17, 2007 IP
  3. gaspacho

    gaspacho Guest

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ok i see where the problem was...
    i added one more case and transformed it into

    switch ($x):
    {
    case "1":
    ...
    break;

    case "2":
    ...
    break;
    }

    and now im getting:

    Parse error: parse error,unexpected '{', expecting `T_ENDSWITCH' or `T_CASE' or `T_DEFAULT' in . ...

    it points to line 11:

    10: switch (...):
    11: {

    What does that mean?
     
    gaspacho, Nov 17, 2007 IP
  4. decepti0n

    decepti0n Peon

    Messages:
    519
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #4
    There shouldn't be a : there
     
    decepti0n, Nov 17, 2007 IP
  5. gaspacho

    gaspacho Guest

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ok probles solved thank you very much... just beginner here... thank you one more time...

    One more question here:

    Lets say that I have database - named ALPHA
    there are 3 tables in it: dogs, cats, pirates
    every one of these tables has some columns with data in it

    is it possible to create php script that would find out number of tables and print every one of them?

    Thank you very much...
     
    gaspacho, Nov 17, 2007 IP
  6. birdsq

    birdsq Peon

    Messages:
    810
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #6
    you should use sql command:"show tables" :D:D
     
    birdsq, Nov 17, 2007 IP
  7. gaspacho

    gaspacho Guest

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Sounds easy but will it print just the names of the tables or also table contents?
     
    gaspacho, Nov 17, 2007 IP