簡體   English   中英

無法使用mysql和php從我的數據庫中讀取第一行

[英]can't read the first row from my database using mysql and php

我正在嘗試使用MySQL和php從數據庫中檢索數據,但我看不懂第一行,不知道為什么

這是我的代碼

<html>
<body>
<?php
$dbhost="127.0.0.1";
$dbuser="root";
$dbpass="";
$dbname="mss";
$connection=mysql_connect($dbhost,$dbuser,$dbpass,$dbname);
if(mysql_errno()){
die("Database Connection failed:" . mysql_error() . "(" . mysql_errno() .")");} ?>
<?php   $id = (isset($_POST['id']) ? $_POST['id']: "hello"); ?> <br>
<?php   $title = (isset($_POST['title']) ? $_POST['title']: "hello"); ?> <br>
<?php $employee = (isset($_POST['employee']) ? $_POST['employee']: "hello");  ?> <br>
<?php  $participant = (isset($_POST['participant']) ? $_POST['participant']: "hello"); 
$starttime = (isset($_POST['starttime']) ? $_POST['starttime']: "hello"); 
$endtime = (isset($_POST['endtime']) ? $_POST['endtime']: "hello"); 
$day = (isset($_POST['day']) ? $_POST['day']: "hello");
$Lines = explode("\n", $participant);
foreach($Lines as $line)
{
echo $line;
mysql_select_db('mss');
$q1="select Availability from E_schedule where StartTime='$starttime' and Day='$day'";
$result = mysql_query( $q1, $connection );
$info= mysql_fetch_array($result);
echo $info['Availability'];
if ($info['Availability'] == 1)
{
    echo ("You can't make a meeting at that time, Please Select another Day or     time");
    Break;
}
if($result == FALSE) 
{
    die(mysql_error()); 
}   
}
?>
<br><?php $day = (isset($_POST['day']) ? $_POST['day']: "hello"); ?> <br>
<?php $starttime = (isset($_POST['starttime']) ? $_POST['starttime']: "hello"); ?><br>
<?php $endtime = (isset($_POST['endtime']) ? $_POST['endtime']: "hello"); ?><br>
<?php  $room = (isset($_POST['room']) ? $_POST['room']: "hello"); ?> <br>
</body>
</html>

我嘗試了很多事情,但任何人都無法解決的同樣問題... ??

<html>
<body>
    <?php
    //Try using Error Reporting On
    error_reporting(E_ALL);
    ini_set('diplay_errors', 'on');

    $dbhost = "127.0.0.1";
    $dbuser = "root";
    $dbpass = "";
    $dbname = "mss";
    $connection = mysql_connect($dbhost, $dbuser, $dbpass, $dbname);
    if (mysql_errno()) {
        die("Database Connection failed:" . mysql_error() . "(" . mysql_errno() . ")");
    }
    mysql_select_db('mss');
    ?>
    <?php echo $id = (isset($_POST['id']) ? $_POST['id'] : "hello"); ?> <br>
    <?php echo $title = (isset($_POST['title']) ? $_POST['title'] : "hello"); ?> <br>
    <?php echo $employee = (isset($_POST['employee']) ? $_POST['employee'] : "hello"); ?> <br>
    <?php
    $participant = (isset($_POST['participant']) ? $_POST['participant'] : "hello");
    $starttime = (isset($_POST['starttime']) ? $_POST['starttime'] : "hello");
    $endtime = (isset($_POST['endtime']) ? $_POST['endtime'] : "hello");
    $day = (isset($_POST['day']) ? $_POST['day'] : "hello");
    $Lines = explode("\n", $participant);
    foreach ($Lines as $line) {
        echo $line;
        $q1 = "select Availability from E_schedule where StartTime='$starttime' and Day='$day'";
        $result = mysql_query($q1, $connection);
        if ($result == FALSE) {
            die(mysql_error());
        } else {
            $info = mysql_fetch_array($result);
            echo $info['Availability'];
            if ($info['Availability'] == 1) {
                echo ("You can't make a meeting at that time, Please Select another Day or     time");
                Break;
            }
        }
    }
    ?>
    <br><?php echo $day = (isset($_POST['day']) ? $_POST['day'] : "hello"); ?> <br>
    <?php echo $starttime = (isset($_POST['starttime']) ? $_POST['starttime'] : "hello"); ?><br>
    <?php echo $endtime = (isset($_POST['endtime']) ? $_POST['endtime'] : "hello"); ?><br>
    <?php echo $room = (isset($_POST['room']) ? $_POST['room'] : "hello"); ?> <br>
</body>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM