Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 数据未保存在我的数据库中_Php_Html_Mysql - Fatal编程技术网

Php 数据未保存在我的数据库中

Php 数据未保存在我的数据库中,php,html,mysql,Php,Html,Mysql,我希望你做得很好。我遇到了一个无法将数据插入数据库的问题。原因有很多,所以请不要把它看作是重复的问题。我检查了我的密码。对于一个表,它保存数据,但对于该表则不保存。它显示未找到同一页,并且本地数据库中未保存任何数据。我希望你们能帮助我,伙计们。提前感谢。:) 以下是一些有用的代码: <?php include 'Header.php'; ?> <style> #first { //margin-right: 100%; //

我希望你做得很好。我遇到了一个无法将数据插入数据库的问题。原因有很多,所以请不要把它看作是重复的问题。我检查了我的密码。对于一个表,它保存数据,但对于该表则不保存。它显示未找到同一页,并且本地数据库中未保存任何数据。我希望你们能帮助我,伙计们。提前感谢。:) 以下是一些有用的代码:

    <?php
include 'Header.php';
?>
<style>
    #first {
        //margin-right: 100%;
        //clear: both;

    }
    #first > img {
        display: inline-block;
        //float: left;
    }
    #first > p {
        //float: left;
        display: inline-block;
        //margin-left: 60px;
        //margin-bottom: 120px;
    }

</style>
<!-- Post content here -->

<!-- Then cmments below -->
<h1>Comments</h1>
<!--<?php ?>
if (isset($_GET['id'])) {
    $id = $_GET['id'];
} elseif (isset($_POST['id'])) {
    $id = $_POST['id'];
} else {
    echo '<p class="error"> Error has occured</p>';

    include 'footer.html';

    exit();
}

$db = new Database();
  $dbc = $db->getConnection();

  $display = 10; //number of records per page
  $pages;

if(isset($_GET['p']) ) //already calculated
{
    $pages=$_GET['p'];  
}
else
{
//use select count() to find the number of users on the DB    
    $q = "select count(comment_id) from comments";
    $r = mysqli_query($dbc, $q);
    $row = mysqli_fetch_array($r, MYSQLI_NUM);
    $records=$row[0];

    if($records > $display ) //calculate the number of pages we will need
      $pages=ceil($records/$display);  
    else
      $pages = 1;
}

//now determine where in the database to start 
if(isset($_GET['s']) ) //already calculated
   $start=$_GET['s'];  
else
    $start = 0;

 //use LIMIT to specify a range of records to select 
 // for example LIMIT 11,10 will select the 10 records starting from record 11
  $q = "select * from users order by $orderby LIMIT $start, $display";

  $r = mysqli_query($dbc, $q);

/*if ($r)
{*/

$result = mysql_query("SELECT * FROM comments WHERE video_id= '" + + "'");
//0 should be the current post's id
while($row = mysql_fetch_object($result))
{
?>
<div class="comment">
By: <!--<?php /* echo $row->author; //Or similar in your table ?>
  <p>
  <?php echo $row->body; ?>
  </p>
  </div>
  <?php
  /*} */
?>*/-->
<h1>Leave a comment:</h1>
<form action="Comment.php" method="post">
    <!-- Here the shit they must fill out -->
    <input type="text" name="comment" value="" />
    <input type="hidden" name="submitted" value="TRUE" />
    <input type="submit" name="submit" value="Insert"/>
</form>';

<?php
if (isset($_POST['submitted'])) {
    $comment = '';

    $errors = array();

    if (empty($_POST['comment']))
        $errors[] = 'You should enter a comment to be saved';
    else
        $comment = trim($_POST['comment']);



    if (empty($errors)) {
        include 'Comments_1.php';
        $comment_2 = new Comments();
        $errors = $comment_2->isValid();
        $comment_2->Comment = trim($_POST['comment']);
        $comment_2->UserName = hamed871;
        $comment_2->Video_Id = 1;
        if ($comment_2->save()) {
            echo '<div class="div_1"><div id="div_2">' .
            '<h1>Thank you</h1><p> your comment has been'
                    . ' posted successfully</p></div></div>';
        }
    }
//First check if everything is filled in
    /* if(/*some statements *//* )
      {
      //Do a mysql_real_escape_string() to all fields

      //Then insert comment
      mysql_query("INSERT INTO comments VALUES ($author,$postid,$body,$etc)");
      }
      else
      {
      die("Fill out everything please. Mkay.");
      }
      ?>

      id (auto incremented)
      name
      email
      text
      datetime
      approved--> */
}
    ?>
    <!--echo '--><div id="first">
        <img src="http://www.extremetech.com/wp-content/uploads/2013/11/emp-blast.jpg?type=square" height="42" width="42"/>
        <p>hamed1</p>
    </div><!--';-->
    <dl>
        <dt>comment1</dt>
        <dd>reply1</dd>
        <dd>reply2</dd>
    </dl>
    <!--//}
    /*else
    {

    }*/
    ?>-->
    <?php
    include 'Footer.php';
    ?>

#首先{
//保证金权利:100%;
//明确:两者皆有;
}
#第一个>img{
显示:内联块;
//浮动:左;
}
#第一>p{
//浮动:左;
显示:内联块;
//左边距:60像素;
//边缘底部:120px;
}
评论
留下评论:
';

我在登台站点上工作时遇到了这种问题,因为网络主机可能有不同的限制和严格的限制。现在我所做的是更改文件名,例如:

类名应该与文件名匹配,因为它区分大小写

Comment.php

class Comment extends DBConn {

function __construct () {
parent::__construct ();
}

//code here..

 }

你能粘贴输出吗?@LajosArpad这里我试过把这一行
(isset($\u POST['submitted'])
改成
(isset($\u POST['submit']))
Hamed,你的评论在哪里。php在项目中吗?@LajosArpad在我所有的类和其他网页所在的同一个项目文件夹中
class Comment extends DBConn {

function __construct () {
parent::__construct ();
}

//code here..

 }