benji87 Posted March 27, 2007 Share Posted March 27, 2007 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(); } ?> Quote Link to comment Share on other sites More sharing options...
DeathStar Posted March 27, 2007 Share Posted March 27, 2007 Why are you getting this error: :\ mysql_numrows() Code seems to be fine. Quote Link to comment Share on other sites More sharing options...
benji87 Posted March 27, 2007 Author Share Posted March 27, 2007 I dont know, i think the variables might not be parsing through the url for some reason?? Quote Link to comment Share on other sites More sharing options...
r-it Posted March 27, 2007 Share Posted March 27, 2007 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? Quote Link to comment Share on other sites More sharing options...
benji87 Posted March 27, 2007 Author Share Posted March 27, 2007 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.