致命错误:在第19行的dev/add_comment.php中调用未定义的函数redirect() [英] Fatal error: Call to undefined function redirect() in dev/add_comment.php on line 19

查看:58
本文介绍了致命错误:在第19行的dev/add_comment.php中调用未定义的函数redirect()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不确定即时通讯是否只是对重定向或其他一些行有问题 所以这是我的档案 add_comment.php

Im not sure if im just having a problem with the redirect or also with some other lines so here are my files add_comment.php

<?php

include ('connection.php');

$id = $_GET['id'];
$name = $_POST['name'];
$email = $_POST['email'];
$website = $_POST['website'];
$content = $_POST['content'];
$date = date('F j<\s\up>S</\s\up>, Y');
//$expire = time()+60*60*24*30;
//setcookie('name', $_POST['name'], $expire, '/');
//setcookie('email', $_POST['email'], $expire, '/');
//setcookie('website', $_POST['website'], $expire, '/');

mysql_query("INSERT INTO blog_comments (post_id,name,email,website,content,date) VALUES ('".$id."', '".$name."', '".$email."', '".$website."', '".$content."', '".$date."')");

mysql_query("UPDATE blog_posts SET num_comments=num_comments+1 WHERE id='$id' LIMIT 1");
redirect('dev/view_post.php?id='.$_GET['id'].'#post-'.mysql_insert_id());
?>

post_view.php

post_view.php

    <?php
// post_view.php
include ('connection.php');
//get id from the link
$id = $_GET['id'];


$query = "SELECT * FROM blog_posts WHERE id = '$id'";
$result = mysql_query($query) or die (mysql_error());


while($row = mysql_fetch_assoc($result))
{
    echo '<h2>'.$row['title'].'</h2>';
    echo '<em>Posted '.date('F j<\s\up>S</\s\up>, Y', $row['date_posted']).'</em><br/>';
    echo nl2br($row['post_content']).'<br/>';
    echo '<a href="dev/edit_post.php?id='.$_GET['id'].'">Edit</a> | <a href="dev/delete_post.php?id='.$_GET['id'].'">Delete</a> | <a href="dev/blog.php">View All</a>';
} 




//comments section
echo '<hr/>';
$query2 = "SELECT * FROM blog_comments where post_id = '$id' ORDER BY date ASC";
$result2 = mysql_query($query2) or die (mysql_error());
while ($row2 = mysql_fetch_assoc($result2)) {
    echo $row2['name'];
}


echo '</ol>';

echo <<<HTML
<form method="post" action="dev/add_comment.php?id={$_GET['id']}">
    <table>
        <tr>
            <td><label for="name">Name:</label></td>
            <td><input name="name" id="name"/></td>
        </tr>
        <tr>
            <td><label for="email">Email:</label></td>
            <td><input name="email" id="email"/></td>
        </tr>
        <tr>
            <td><label for="website">Website:</label></td>
            <td><input name="website" id="website"/></td>
        </tr>
        <tr>
            <td><label for="content">Comments:</label></td>
            <td><textarea name="content" id="content"></textarea></td>
        </tr>
        <tr>
            <td><input type="submit" value="Post Comment"/></td>
        </tr>
    </table>
</form>
HTML;
?>

必须是什么问题? 我是php新手.谢谢你们 我收到错误消息致命错误:在第19行的dev/add_comment.php中调用未定义的函数redirect()"

What must be the problem? Im new to php. Thanks guys I'm getting the error "Fatal error: Call to undefined function redirect() in dev/add_comment.php on line 19"

推荐答案

redirect()既不是PHP函数,也不是脚本中定义的函数.如果您尝试重定向,请使用header():

redirect() is neither a PHP function or a defined function in your script. If you are trying to redirect, use header():

header("location: dev/view_post.php?id='.$_GET['id'].'#post-'.mysql_insert_id()");
exit(); //note, I didn't test this for single/double quote accuracy, that's on you

这篇关于致命错误:在第19行的dev/add_comment.php中调用未定义的函数redirect()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆