Jump to content

Help needed with forums


suicide-boy

Recommended Posts

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  8) 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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;
}


 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  '".$_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.

Link to comment
Share on other sites

  '".$_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 =/

Link to comment
Share on other sites

//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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

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.