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
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
Share on other sites

Ignore that sorry it shouldnt be there! Well i dont understand what difference changing the query would make?? That part works fine its just the redirecting thats the problem it doesnt parse the variables through the url for some reason!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.