php - 在 X 行的 ?/login.php 中解析错误 : syntax error, 文件意外结束

标签 php html css

<分区>

我收到这个错误:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in ?/config.php on line 9

代码:

<!-- Config.php Code -->
    <?php session_start();

    //mysql connection
    $con = mysql_connect("localhost","digmoorc","community20");
    mysql_select_db("digmoorc_EHUB",$con);

    function getUserData($userID) {
        $query=mysql_query("select 'userID' from tbl_users where userID=$userID limit 1");
    while($row = mysql_fetch_array($query))
    if ($query === false) mysql_error();
    {
    }
    }
    ?>

最佳答案

试试这个

<?php

    require("config.php");
$error = '';
    if(isset($_POST['Submit'])) {

        $userName=$_POST['userName'];
        $passWord=$_POST['passWord'];

        $query=mysql_query("select user ID from tbl_users where userName='$userName' and passWord='$passWord' limit 1");
    if(mysql_num_rows($query)==1) {
    //login success
    $data=mysql_fetch_array($query,1);
    $_SESSION['userID']=$data['userID'];
    header("location:dashboard.php");
    exit();

    }else{
    //login failed
    $error="Invalid Login";
    }
}

    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <html>
    <head>
    <head profile="http://www.w3.org/2005/10/profile">

    <link rel="icon" type="image/png" href="#" />

        <!--META DATA -->
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta http-equiv="Content-Language" content="en" />

        <link rel="credits" type="rel" href="http://www.cultivatecreative.co.uk/" />

        <!-- STYLESHEETS -->
        <style>
        body {
            background: #e8f5f6;
            font-family: Arial, Helvetica, sans-serif;
            font-size: 12px;
            text-rendering: optimizeLegibility;
            font-weight: normal;
            color: #444;
            padding-top: 39px;
            -webkit-tap-highlight-color: #62A9DD;
            }
        #header {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 39px;
            padding: 0;
            background: #59c5c4;
            -moz-box-shadow:inset 0 0 10px #2f6b8f;
            -webkit-box-shadow:inset 0 -5px 10px #2f6b8f;
            box-shadow:inset 0 0 10px #2f6b8f;
            }
        #wrapper {
            width: 540px;
            margin: 100px auto;
            padding: 30px;
            background: #fff;
            }
        a.logo {
            margin: 18px auto 30px;
            display: block;
            width: 244px;
            height: 107px;
            background: url(file:///C|/Users/Daniel/Downloads/Evermore%20HUB/evermoorhub-logo.png) no-repeat;
            text-indent: -9999px;
            border: none;
            }   
        h1 {
            text-align: center;
            font-size: 2.833em; /* 22px */
            font-family: arial, sans-serif;
            color: #444;
            font-weight: normal;
            color: #59c5c4;
            }
        a {
            color: #000;
            text-decoration: none;
        }

        a:hover {
            border-bottom: none;
        }

        p {
            text-align: center;
            font-size: 1em; /* 22px */
            font-family: arial, sans-serif;
            color: #000;
            font-weight: normal;
            color: #000;        
        }
        #wrapper table {
        background-color: #59c5c4;
    }

        </style>

        <title>Evermoor HUB | Login</title>

    </head>

    <body>
    <div id="header"></div>
    <div id="wrapper">
    <a class="logo" href="http://www.evermoorhub.co.uk" title="Webpage design:">Daniel Woods</a>
    <h1><strong><center>User Login</center></strong></h1>
    <form action=""  method="post">
    <table width="100%" border="0" cellpadding="3" cellspacing="1" class="table">
      <?php if(isset($error)); ?>

      <td colspan="2" align="center"><strong class="error"><?php echo $error; ?></strong></td>
      </tr>
        <td width="50%" align="right">Username:</td>
        <td width="50%"><input name="userName" type="text" id="userName"></td>
      </tr>
      <tr>
        <td align="right">Password:</td>
        <td><input type="password" name="passWord" id="passWord"></td>
      </tr>
      <tr>
        <td align="right">&nbsp;</td>
        <td><input type="submit" name="Submit" id="Submit" value="Submit"></td>
      </tr>
    </table>
    </form>
    </div> <!-- Wrapper -->
    </body>
    </html>

关于php - 在 X 行的 ?/login.php 中解析错误 : syntax error, 文件意外结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31266325/

上一篇:css - flex 圆形英雄按钮

下一篇:HTML5 - 基本关键帧二对象

相关文章:

javascript - 每次单击 jQuery 中的一个子 li 时,如何获取父 li?

html - 动画时 twitter bootstrap 轮播问题

php - MySQL 多个 And 和 or 匹配没有结果

php - 当名称存在或添加时收到消息

html - 如何将对象对齐到页面中心?

css - Bootstrap - 关于字体文件(.eot .svg .ttf .woff 和 .woff2)的角色和用法

java - Java中如何通过Document接口(interface)访问外部样式表?

PHP MySQL 只更新一个单元格,而不是整行

php - 以可扩展的方式计算文字、图像、视频和音频文件数量?

html - 相当于在Outlook中 float