dominic600 Posted September 13, 2011 Share Posted September 13, 2011 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."; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/247015-not-sure-whats-going-on-here/ Share on other sites More sharing options...
Pikachu2000 Posted September 13, 2011 Share Posted September 13, 2011 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) Quote Link to comment https://forums.phpfreaks.com/topic/247015-not-sure-whats-going-on-here/#findComment-1268581 Share on other sites More sharing options...
dominic600 Posted September 13, 2011 Author Share Posted September 13, 2011 i fixed the parentheses and now i get a new error after fixing that other line. new error is unexpected } in line 25 Quote Link to comment https://forums.phpfreaks.com/topic/247015-not-sure-whats-going-on-here/#findComment-1268582 Share on other sites More sharing options...
Pikachu2000 Posted September 13, 2011 Share Posted September 13, 2011 And that is caused by this: And this line is missing something header("Location: view_topic.php?cid".$cid."$tid=".$new_topic_id) Quote Link to comment https://forums.phpfreaks.com/topic/247015-not-sure-whats-going-on-here/#findComment-1268583 Share on other sites More sharing options...
Pandemikk Posted September 13, 2011 Share Posted September 13, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/247015-not-sure-whats-going-on-here/#findComment-1268586 Share on other sites More sharing options...
dominic600 Posted September 13, 2011 Author Share Posted September 13, 2011 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 ; Quote Link to comment https://forums.phpfreaks.com/topic/247015-not-sure-whats-going-on-here/#findComment-1268590 Share on other sites More sharing options...
Pandemikk Posted September 13, 2011 Share Posted September 13, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/247015-not-sure-whats-going-on-here/#findComment-1268594 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.