suicide-boy Posted July 11, 2007 Share Posted July 11, 2007 Hi all. Post number 1. WEEEeeeeee Anyways. I've been wrking on a site that has been in large demand a number of months - suicide Boys (www.suicide-boys.co.uk) and I'm working on a forum but each time I try a post test I get a message about there being an error on line 3. I've retyped it out and corrected any errors but it still won't work. Here's the link to see the message: www.suicide-boys.co.uk/addtopic.html try something and then click "Post" and hopefully you'll be cleverer than me and know what it means. I'm gonna get working on something better with the profiles but I have set up an account somewhere where the info get's sent. Feel free to join Thanks, Pete =] EDIT: Here's the code just so you know And for the record: It was copied from a book I bought so maybe they have it wrong?! Or it could be my bad computer <?php //check for required fields from the form if ((!$_POST["topic_owner"]) ¦¦ (!$_POST["topic_title"]) ¦¦ (!$_POST[ "post_text"])) { header("Location: addtopic.html"); exit; } //connect to server $mysqli_connect("localhost", "joeuser", "somepass", "testDB"); //create and issue the first query $add_topic = "INSERT INTO forums_topics (topic_title, topic_create_ time, topic_owner) VALUES ("*.$_POST["topic_title"] ."',now(), '".$_POST[" topic_owner"].*')"*; $add_topic_res = mysqli_query($mysqli, $add_topic_sql) //get the id of the last query $topic_id = mysqli_insert_id($mysqli); //create and issue the 2nd query $add_post_sql = "INSERT INTO forum_posts (topic_id,post_text, post_create_time, post_owner) VALUES ('".$topic_id."', '".$_POST["post_text"]."', now(), '".$_POST["topic_owner"]."')"; $add_post_res = mysqli_query($mysqli, $add_post_sql) or die(mysqli_error($mysqli)); //close connection to MYSQL mysqli_close($mysqli); //create msg for user $display_block = "<P>The <strong>".$_POST["topic_title"]."</strong> topic has been created.</>"; ?> <HTML> <head> <title>New Topic Added</title> </head> <body> <h1>New Topic Added</h1> <?php echo $display_block; ?> </body> </html> Quote Link to comment Share on other sites More sharing options...
per1os Posted July 11, 2007 Share Posted July 11, 2007 Parse error: parse error, unexpected T_STRING in \\nas38ent\domains\s\suicide-boys.co.uk\user\htdocs\do_addtopic.php on line 3 Post the code for do_addtopic.php We need to see code to help. Quote Link to comment Share on other sites More sharing options...
suicide-boy Posted July 11, 2007 Author Share Posted July 11, 2007 Parse error: parse error, unexpected T_STRING in \\nas38ent\domains\s\suicide-boys.co.uk\user\htdocs\do_addtopic.php on line 3 Post the code for do_addtopic.php We need to see code to help. posted. I thought of it just after I clicked "Post"......idiot I am. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted July 11, 2007 Share Posted July 11, 2007 This is what I got for line 3: if ((!$_POST["topic_owner"]) ¦¦ (!$_POST["topic_title"]) ||(!$_POST[ "post_text"])) { Correct me if I am wrong. I did this simple one, Try it. $topic_owner=$_POST['topic_owner']; $topic_title=$_POST['topic_title']; $post_text=$_POST['post_text']; if(empty($topic_owner) || empty($topic_title) || empty($post_text)){ header("Location: addtopic.html"); exit; } Quote Link to comment Share on other sites More sharing options...
suicide-boy Posted July 11, 2007 Author Share Posted July 11, 2007 This is what I got for line 3: if ((!$_POST["topic_owner"]) ¦¦ (!$_POST["topic_title"]) ||(!$_POST[ "post_text"])) { Correct me if I am wrong. I did this simple one, Try it. $topic_owner=$_POST['topic_owner']; $topic_title=$_POST['topic_title']; $post_text=$_POST['post_text']; if(empty($topic_owner) || empty($topic_title) || empty($post_text)){ header("Location: addtopic.html"); exit; } That seems to have worked but now I'm getting errors about line 18. Grrrrr. Well, I guess that's the result of being a 1st timer then. Quote Link to comment Share on other sites More sharing options...
teng84 Posted July 11, 2007 Share Posted July 11, 2007 tell us whats the error Quote Link to comment Share on other sites More sharing options...
suicide-boy Posted July 11, 2007 Author Share Posted July 11, 2007 Error: Parse error: parse error, unexpected '.' in \\nas38ent\domains\s\suicide-boys.co.uk\user\htdocs\do_addtopic.php on line 18 Lines 16 - 20: //create and issue the first query $add_topic = "INSERT INTO forum_topics (topic_title, topic_create_ time, topic_owner) VALUES ("*.$_POST["topic_title"] ."',now(), '".$_POST[" topic_owner"].*')"*; $add_topic_res = mysqli_query($mysqli, $add_topic_sql) As you can tell I am a total n00bie to php Quote Link to comment Share on other sites More sharing options...
per1os Posted July 12, 2007 Share Posted July 12, 2007 '".$_POST[" topic_owner"]."')"; // removed the * //create and issue the first query $add_topic = "INSERT INTO forum_topics (topic_title, topic_create_" . "time, topic_owner) VALUES ("*.$_POST["topic_title"] ."',now(), '".$_POST[" topic_owner"]."')"; $add_topic_res = mysqli_query($mysqli, $add_topic_sql) Try that. Quote Link to comment Share on other sites More sharing options...
suicide-boy Posted July 12, 2007 Author Share Posted July 12, 2007 '".$_POST[" topic_owner"]."')"; // removed the * //create and issue the first query $add_topic = "INSERT INTO forum_topics (topic_title, topic_create_" . "time, topic_owner) VALUES ("*.$_POST["topic_title"] ."',now(), '".$_POST[" topic_owner"]."')"; $add_topic_res = mysqli_query($mysqli, $add_topic_sql) Try that. I'm getting the same message again (I think) Parse error: parse error, unexpected '.' in \\nas38ent\domains\s\suicide-boys.co.uk\user\htdocs\do_addtopic.php on line 18 I used the above lines. It might be my computer, but if it's not working on yours either maybe it's my coding =/ Quote Link to comment Share on other sites More sharing options...
per1os Posted July 12, 2007 Share Posted July 12, 2007 //create and issue the first query $add_topic = "INSERT INTO forum_topics (topic_title, topic_create_" . "time, topic_owner) VALUES ('".$_POST["topic_title"] ."',now(), '".$_POST[" topic_owner"]."')"; $add_topic_res = mysqli_query($mysqli, $add_topic_sql) I don't know why you were using *'s but there was another star by topic_title, removed it try that. Quote Link to comment Share on other sites More sharing options...
suicide-boy Posted July 12, 2007 Author Share Posted July 12, 2007 The above code worked but now it has an error on line 23 ??? Parse error: parse error, unexpected T_VARIABLE in \\nas38ent\domains\s\suicide-boys.co.uk\user\htdocs\do_addtopic.php on line 23 I'm guessing there's summing up with the variable but I dunno what. Gawd this is getting annoying Line 20 - 24: $add_topic_res = mysqli_query($mysqli, $add_topic_sql) //create and issue 2nd query $topic_id = mysqli_insert_id($mysqli); Sorry 'bout all this hassle. Quote Link to comment Share on other sites More sharing options...
chocopi Posted July 12, 2007 Share Posted July 12, 2007 missing ; $add_topic_res = mysqli_query($mysqli, $add_topic_sql) should be $add_topic_res = mysqli_query($mysqli, $add_topic_sql); ~ Chocopi Quote Link to comment Share on other sites More sharing options...
suicide-boy Posted July 12, 2007 Author Share Posted July 12, 2007 missing ; $add_topic_res = mysqli_query($mysqli, $add_topic_sql) should be $add_topic_res = mysqli_query($mysqli, $add_topic_sql); ~ Chocopi I removed and put the ; back in for a test. It's not working but right now I've given up with the forums/put them on hold while I re-do the templates and make it look better. 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.