PHP echo html表错误

PHP echo html表错误,php,html,html-table,echo,Php,Html,Html Table,Echo,我使用数据库中的数据创建了一个表,为了创建它,我使用了一个循环从我需要的列中获取每一条数据。现在,我在输入的HTMLonClick中调用了javascript函数。但是,我不断地得到一个错误。该函数似乎确实起作用,只是实际的echo似乎给出了错误。在第58行,您可以看到我正在创建一个表并插入行 更新 我的javascript函数正在工作。错误是当它试图设置宽度和对齐方式时。 我得到的错误是: 未捕获的语法错误:无效或意外标记 <?php ob_start(); sessio

我使用数据库中的数据创建了一个表,为了创建它,我使用了一个循环从我需要的列中获取每一条数据。现在,我在输入的
HTML
onClick
中调用了
javascript
函数。但是,我不断地得到一个错误。该函数似乎确实起作用,只是实际的
echo
似乎给出了错误。在第58行,您可以看到我正在创建一个表并插入行

更新

我的javascript函数正在工作。错误是当它试图设置宽度和对齐方式时。 我得到的错误是:

未捕获的语法错误:无效或意外标记

<?php
    ob_start();
    session_start();
    require_once 'dbconnect.php';
    if( !isset($_SESSION['user']) ) {
        header("Location: index.php");
        exit;
    }
    $deny = array("222.222.222", "333.333.333");
    if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
       header("location: http://www.google.com/");
       exit();
    }
    $res=mysqli_query($con,"SELECT * FROM users WHERE userId=".$_SESSION['user']);
    $userRow=mysqli_fetch_array($res);
?>
<!DOCTYPE html>
<html>
    <?php header("Access-Control-Allow-Origin: http://www.py69.esy.es"); ?>
    <head>
        <title>ServiceCoin</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" href="assets/css/bootstrap.min.css" type="text/css"  />
        <link rel="stylesheet" href="scripts/home/index.css" />
    </head>
    <body>
        <ul>
            <li><a href="#" class="a">ServiceCoin.com(image)</a></li>
            <li><a href="logout.php?logout" class="a">Sign Out</a></li>
            <li><a href="#" class="a">Contact</a></li>
            <li><a href="#" class="a">Get Service Coins</a></li>
            <li><a href="#" class="a">News</a></li>
            <li><a href="settings.php" class="a">Settings</a></li>
            <li><a href="#" class="a">Referrals</a></li>
            <li><a href="service.php" class="a">Services</a></li>
            <li><a href="home.php" class="a">Home</a></li>
        </ul>
        <br /><br />
        <center>
        <h3>Welcome, <?php echo $userRow['userName']; ?>. You Currently Have <span id="services"><?php echo $userRow['userServices']; ?></span> Services</h3>
        <p id="error"></p>
        <button onclick="send_coins()" class="button">Send Coins</button>
        <button onclick="create_service()" class="button">Create A Service</button>
        <button onclick="send_coins()" class="button">My Services</button>
        <h3>View Services</h3>
        <span><?php 
        $users = 1;
        $num = 1;
        echo "<center><table width=1000><th>Buy</th><th>Service Name</th><th>Service Cost</th><th>Service Description</th><th>Service Provider Name</th>";
        while($users < 100 && $num < 100){
            $res=mysqli_query($con,"SELECT * FROM users WHERE userId=".$users);
            $userRow=mysqli_fetch_array($res);
            $id = 0;
            while($id != 10){
                $id = $id + 1;
                if($userRow['userService'.$id] === 'null'){
                }else if(!empty($userRow['userService'.$id])){
                echo "<tr class=services ><td name=".$num."><input type=submit onClick='buy(".$userRow['userService'.$id].",".$userRow['userServiceCost'.$id].",".$userRow['userServiceEmail'].")'></td><td width='250' align='center'>".$userRow['userService'.$id]."</td><td width='250' align='center'>".$userRow['userServiceCost'.$id]."</td><td width='250' align='center'>".$userRow['userServiceDes'.$id]."</td><td width='250' align='center'>".$userRow['userServiceName'.$id]."</td></tr>";  

                //echo $id."Error: ".$con->error;           
                $num = $num + 1;
                }
            }
            $users = $users + 1;
        }
        echo "All Services Loaded";
        echo "</table></center>";
        ?></span>
            <span class="text-danger"><?php echo $msg; ?></span>
        </center>
    </body>
    <script lang="text/javascript" src="scripts/home/index.js"></script>    
    <script type="text/javascript">


function buy(sid, scost, semail){
    console.log(sid,scost,semail);
}

</script>
</html>
<?php ob_end_flush(); ?>

服务币


欢迎您当前有服务

寄硬币 创建服务 我的服务 查看服务 功能购买(sid、scost、semail){ 日志(sid、scost、semail); }
正如我在上面的评论中提到的,您需要对所有属性和JS调用使用引号。此外,请记住,onClick的内容必须是有效的JS。因此,作为参数传递给函数的字符串应该在引号中


echo'.$userRow['userService'.$id].$userRow['userServiceCost'.$id].$userRow['userServiceDes'.$id].$userRow['userServiceName'.$id].'

可能重复请查看编辑
如图所示放置单引号,看看是否有帮助。不,这似乎不起作用。我仍然收到相同的错误。我将把它放在问题中。请您发布这行回音“是的,对不起,我注意到了,忘了在这里更新代码。对不起,那没办法