简体   繁体   中英

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

I am trying to retrieve data from the database using MySQL and php and I can't read the first row don't know why

here is my code

<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>

I tried so many things and its not working anybody had the same problem...??

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM