Uncaught syntaxerror unexpected token }

I have this code:

<?php 
session_start();?>
<!DOCTYPE html>
<html>
<head>
<title>Narcis Bet</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/style.css" type="text/css">
<script type="text/javascript" src="js/script.js"></script>
</head>
<body>
    <header>
        <div id="top">
        <a href="../index.php"><img src="images/logo.png" width="400" height="140" alt="logo"/></a>

        <?php

            if(!isset($_SESSION['utilizator']))
            {
            ?>
        <div id="topright">
        <form action="api/login.php" method="POST" id="toprightt">
            <input type="text" name="username"/>        
            <input type="password" name="password"/>
            <input type="submit" value="Login"/>
        </form>
        </div>

        <a href="#" id="toprightimg"><img src="images/facebook.png" alt="facebook"/></a>
        <a href="#" id="topright">Contact</a>
        <a href="#" id="topright">Termeni și condiții</a>
        </div>
    </header>

    <?php
                if(isset($_SESSION['eroare']))
                {
                    echo $_SESSION['eroare'];
                    unset($_SESSION['eroare']);
                }
            }
            else
            {
                echo "<h1 id="."topright".">Bun venit,".$_SESSION['utilizator']."</h1>";

            ?>
            <form action="api/logout.php" id="toprightl">
                    <input type="submit" value="Logout"/>
                </form>

            <nav class="nav">
            <ul>
                <li><a href="pariuri.php">Pariuri</a></li>
                <li><a href="#Section3">Loto</a></li>
                <li><a href="#Section2">Despre</a></li>
                <li><a href="regulament.php">Regulament</a></li>
            </ul>
            </nav>
            <section class="main">
            <table class="tableright" id="talon">
                <tr>
                    <th>Cod</th>
                    <th>Eveniment</th>
                    <th>Data</th>
                    <th>Cota</th>
                </tr>
            </table>
            <table class="table1"  >
                <thead>
                            <tr><th colspan="6" class="th1">FOTBAL</th></tr>
                            <tr>
                                <th>Cod.</th>
                                <th>Eveniment</th>
                                <th>data</th>
                                <th >1</th>
                                <th >X</th>
                                <th >2</th>
                            </tr>
                        </thead>

            <?php 
            $handle = @fopen("../res/fotbal.txt", "r");
                if ($handle)
                {
                    while (($buffer = fgets($handle, 4096)) !== false)
                    {
                        $pariu=json_decode($buffer,true);
                        echo "<tr>";
                        echo "<td id='cod'>".$pariu["id"]."</td>";
                        echo "<td id='ev'>".$pariu['eveniment']."</td>";
                        echo "<td id='data'>".$pariu['data']."</td>";
                        echo "<td class='td1' onclick='FUNCTIE(".$pariu["id"].","".$pariu["eveniment"]."","".$pariu["data"]."",'1')>".$pariu['1']."</td>";
                        echo "<td class='td1' onclick='FUNCTIE(".$pariu["id"].","".$pariu["eveniment"]."","".$pariu["data"]."",'X')>".$pariu['X']."</td>";
                        echo "<td class='td1' onclick='FUNCTIE(".$pariu["id"].","".$pariu["eveniment"]."","".$pariu["data"]."",'2')>".$pariu['2']."</td>";

                        /*echo "<td class='td1'><button onclick='FUNCTIE(".$pariu["id"].","".$pariu["eveniment"]."","".$pariu["data"]."",'1')".$pariu['1']."</button></td>";
                        echo "<td class='td1'><button onclick='FUNCTIE(".$pariu["id"].","".$pariu["eveniment"]."","".$pariu["data"]."",'X')".$pariu['1']."</button></td>";
                        echo "<td class='td1'><button onclick='FUNCTIE(".$pariu["id"].","".$pariu["eveniment"]."","".$pariu["data"]."",'2')".$pariu['1']."</button></td>";
                        */
                        echo "</tr>";
                    }
                    if (!feof($handle))
                    {
                        echo "Error: unexpected fgets() failn";
                    }
                    fclose($handle);
                }


            } ?>
            </table>
            </section>



    </body>
</html>

and the function in javascript:

function FUNCTIE(id,eveniment,data,tip_pariu)
{
    var table=document.getElementById('talon');
    if(table)
    {
        table.innerHTML+="<tr><td>"+id+"</td><td>"+eveniment+"</td><td>"+data+"</td><td>"+tip_pariu+"</td><tr>";
    }
}

and i get this error(uncaught syntaxerror unexpected token }) when i press on the td with onlick function.Please help me !I dont know why i get this error!.......................................................................................................................................................................................................................................................................................................................................................


unless they are all numbers, keywords, functions, or variable names, you should wrap your calls in quotes. so code becomes... also there is a ' left out.

... ... ...
  echo "<td class='td1' onclick='FUNCTIE("".$pariu["id"]."","".$pariu["eveniment"]."","".$pariu["data"]."",1)'>".$pariu["1"]."</td>";
... ... ...

maybe that will work

链接地址: http://www.djcxy.com/p/8036.html

上一篇: Framework7未捕获的SyntaxError:意外的令牌>

下一篇: 未捕获的语法错误意外的令牌}