我刚刚从this下载了一个墙脚本,我将所有内容都安装到我的数据库中。当我运行我的程序时,当我在文本框中输入内容时它显示正常,并且点击发布它什么都不显示。
当我检查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;
}
?>