我刚刚从这里下载了一个墙脚 ,然后将所有内容都设置到了数据库中。 当我运行程序时,当我在文本框中键入内容并单击发布时,它可以正常显示。

当我检查phpMyAdmin时,我在文本框中键入了一些消息,但是单击发布后它没有显示在墙上,但是它显示了消息到数据库?

这是update.php代码:

<?php
    require_once "config.php";
    require_once "helper.php";

    $data = array();
    if(isset($_POST)) {
        $type = $_POST['shareType'];
        $data[':message'] = $_POST['message'];
        $data[':type'] = $_POST['shareType'];
        $data[':location'] = ($type == 'location') ? $_POST['location'] : '';
        $data[':lat'] = ($type == 'location') ? $_POST['lat'] : ''; 
        $data[':lng'] = ($type == 'location') ? $_POST['lng'] : ''; 
        $data[':user_id'] = 1; 
        $data[':video_url'] = ($type == 'videos') ? $_POST['videoUrl'] : '';
        $data[':created'] = time();
        $data[':image'] = '';
        //For image upload
        if($type == 'photos' && !empty($_FILES['image'])) {
            $file_exts = array("jpg", "bmp", "jpeg", "gif", "png");
            $upload_exts = end(explode(".", $_FILES["image"]["name"]));
            if ((($_FILES["image"]["type"] == "image/gif")
            || ($_FILES["image"]["type"] == "image/jpeg")
            || ($_FILES["image"]["type"] == "image/png")
            || ($_FILES["image"]["type"] == "image/pjpeg"))
            && ($_FILES["image"]["size"] < 2000000)
            && in_array($upload_exts, $file_exts))
            {
                $data[':image'] = time().'.jpg';
                move_uploaded_file($_FILES['image']['tmp_name'], 'uploads/'.$data[':image']);
            }
        }
        // End
        $stmt = $db->prepare("INSERT INTO post (user_id, created, type, message, location, lat, lng, image, video_url) VALUES (:user_id, :created, :type, :message, :location, :lat, :lng, :image, :video_url)");
        if($stmt->execute($data)) {
            $id = $db->lastInsertId();
            $stmt = $db->prepare('SELECT * FROM post where id=:id');
            $stmt->execute(array(':id' => $id));
            if($stmt->rowCount() > 0) {
                $row = $stmt->fetch(PDO::FETCH_ASSOC);

            }
        }

        // Templating
        $template = '';
        if(!empty($row)){
            $template .= '<li><div class="timeline-panel">';
            $template .= '<div class="timeline-header">
                            <div class="row">
                                <div class="col-xs-2">
                                  <img class="img-responsive img-rounded" src="http://0.gravatar.com/avatar/43a5669f2e4d2342701ed560d453a0dd?s=50&d=&r=G">
                                </div>
                                <div class="col-xs-8">
                                  <a>Azhagupandian </a> shared '.time_passed($row['created']).'
                                </div>
                              </div>
                        </div>';
          $media = '';
          if($row['type'] === 'photos') {
              $script = $_SERVER['SCRIPT_NAME'];
              $media = '<img class="img-responsive" src="timthumb.php?src='.dirname($script).'/uploads/'.$row['image'].'&w=456&h=300&q=100&s" />';
          } else if($row['type'] === 'location'){
            $media = '<img class="img-responsive" src="http://maps.googleapis.com/maps/api/staticmap?size=500x150&maptype=roadmap\&markers=size:mid%7Ccolor:red%7C'.$row['lat'].','.$row['lng'].'&zoom=7&sensor=false" />';
          } else if($row['type'] === 'videos') {
              $vType = videoType($row['video_url']);
              if($vType === 'youtube'){
                $id = get_youtube_video_id($row['video_url']);
                $media = '<div class="videowrapper">
                  <iframe height="300" src="http://www.youtube.com/embed/'.$id.'" frameborder="0" allowfullscreen></iframe>
                </div>';
              }
              else if($vType === 'vimeo') {
                $id = get_vimeo_video_id($row['video_url']);
                $media = '<div class="videowrapper">
                  <iframe src="http://player.vimeo.com/video/'.$id.'" height="300" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
                </div>';
              }
          }
          $template .= '<div class="timeline-heading">
                           '.$media.'         
                          </div>';
          $template .= '<div class="timeline-body"><p>
              '.$row['message'].'</p>
            </div>';
          $template .= '</div></li>'; 
        }
        echo $template;
    }

?>

  ask by user3553704 translate from so

本文未有回复,本站智能推荐: