Jump to content

Recommended Posts

So im using textwrangler and usually when you click on the '{' or '}' it will highlight everything inbetween them, well on the top one on line 7 it does not, and i tried messing around with it to try to get it to work cause i keep getting an error on line 8 that says "Parse error: syntax error, unexpected '{' in /home/truckste/public_html/create_topic_parse.php on line 8"

 

<?php
if($username){
header("Location: index.php");
exit();
}

if(isset($_POST['topic_submit'])){
if (($_POST['topic_title'] == "" && ($_POST['topic_content'] == "")){
echo "You Did Not Fill In Both Fields. Please Return To The Previous Page.";
exit();
}
else{
requre('scripts/connect.php');
$cid = $_POST['cid'];
$title = $_POST['topic_title'];
$content= $_POST['topic_content'];
$creator = $_POST['uid'];
$sql = "INSERT INTO topics (category_id, topic_title, topic_creator, topic_date, topic_reply_date) VALUES ('".$cid."', '".$title."', '".$creator."', now(), now())";
$res = mysql_query($sql) or die(mysql_error());
$new_topic_id = mysql_insert_id();
$sql2 = "INSERT INTO posts (category_id, topics_id, post_creator, post_content, post_date) VALUES ('".$cid."', '".$new_topic_id."', '".$creator."', '".$content."', now())";
$res2 = mysql_query($sql2) or die(mysql_error());
$sql3 = "UPDATE categories SET last_post_date=now(), last_user_posted'".$creator."', WHERE id='".$cid."' LIMIT 1";
if (($res) && (res2) && (res3)){
header("Location: view_topic.php?cid".$cid."$tid=".$new_topic_id)
}
else{
echo "There Was A Problem Creating Your Topic. Please Try Again.";
}

}


?>

Link to comment
https://forums.phpfreaks.com/topic/247015-not-sure-whats-going-on-here/
Share on other sites

You have parentheses mismatched here

if (($_POST['topic_title'] == "" && ($_POST['topic_content'] == "")){

 

And this line is missing something

header("Location: view_topic.php?cid".$cid."$tid=".$new_topic_id)

Indeed. I also question your random use of string concatenation and reliance on parsing for your variables. While still valid code, surely:

 

header("Location: view_topic.php?cid$cid$tid=$new_topic_id");

Or preferably

header('Location: view_topic.php?cid' . $cid . $tid . '=' . $new_topic_id);

 

would be a better practice of coding.

i got that fixed now thanks!

but can you tell me whats wrong with this line

echo "<tr><td colspan='2'><input type='submit' value='Add Reply' onClick=\ "window.location = post_reply.php?cid=".$cid."&tid=".$tid."\" /><hr /> ";

 

cause im getting an error saying expecting a , or ;

Your backslash needs to be next to the double quote you are expecting, methinks.

 

To explain that error for you, since the double quote was not escaped it terminated that string so now the parser is expecting a , to signify a new parameter to be echoed or a ; to end the statement. What you've given it now is random text. PHP hates random text.

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.