Jump to content

Redirecting help!


benji87

Recommended Posts

Hi all im trying to create a little comments page similar to a shoutbox. Trouble is when i make a post i cant make it redirect correctly  ??? i always get a mysql_numrows() is not a valid resource. Im not sure why it does this but i guess its something to do with me trying to redirect it by parsing variables through the URL. Although i have tried using javascript goback function but i get a similar error. Here is my form submit code:

 

<?
include 'db.php';

$id = $_GET['id'];
$username = $_GET['u'];
$title = $_GET['t'];

$topicid = $_POST['id'];
$comment = $_POST['message'];
$commentby = $_POST['commentby'];

$date = date("j F");

$sql = mysql_query("INSERT INTO ssrfc_noticecomments (topicid, comment, commentby, date)
VALUES('$topicid', '$comment', '$commentby', '$date')") or die (mysql_error());

if(!$sql){
echo 'There has been an error while trying to submit your post.';
} else {

header("Location: http://www.alns.co.uk/ssrfc/member/showcomments.php?id=$id&u=$username&t=$title");	
$id = mysql_insert_id();
}
?>

Link to comment
https://forums.phpfreaks.com/topic/44459-redirecting-help/
Share on other sites

after the header function, shouldnt there be an exit;

 

and another thing, try this for your slq:

$sql = mysql_query("INSERT INTO ssrfc_noticecomments (topicid, comment, commentby, date)
VALUES('".$topicid."', '".$comment."', '".$commentby."', '".$date."')") or die (mysql_error());

 

and I just dont understand what your'e gonna do with the insert_id?

Link to comment
https://forums.phpfreaks.com/topic/44459-redirecting-help/#findComment-215930
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.