Follow me on Twitter @ http://twitter.com/tktutorials Check out my website @ http://www.timkipptutorials.com This is part three of this tutorial series. In part three …
Original source
Follow me on Twitter @ http://twitter.com/tktutorials Check out my website @ http://www.timkipptutorials.com This is part three of this tutorial series. In part three …
Original source
36 responses to “PHP Series – Building A PHP MySQL Forum Tutorial Series Part 3.3 – Creating Topics”
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'now())' at line 6
i dont receive any error but my session name dosn"t display E.g loged in as Damulira why
Good tutorial
my tid do not have a value everytime i create a topic. what should i do? i did exactly what you did in this video, but still no tid. Thanks!
there is a little bug in the if-else logic in create_topic_parse, as it takes input even if one of the field is empty.
it should've been
if(($_POST['topic_title']!=="") && ($_POST['topic_content'] !== "")){
…….all the codes……..
}else{
echo "u must fill both field"
}
I've run into a problem maybe someone can help me?
Its important to note that I am combining this with my own template.
I have the create-topic-parse.php finished and correct.
<?php
if(isset($_POST['submit'])) {
if (($_POST['title'] == "") && ($_POST['content'] == "")) {
echo "You did not fill in both fields. Please return to the previous page. ";
exit();
}
else{
$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, topic_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 categories1 SET last_post_date=now(), last_user_posted='".$creator."' WHERE id='".$cid."' LIMIT 1";
$res3 = mysql_query($sql3) or die(mysql_error());
if(($res) && ($res2) && ($res)) {
header("Location: view_topic.php?cid=".$cid."$tid=".$new_topic_id);
}
else{
echo "There was a problem. Try again.";
}
}
}
?>
I also have the form from the create-topic.php
<form action="create-topic-parse.php" method="post">
<p>Topic Title:<br>
<input type="text" name"title" value="title">
</p>
<p>Topic Content:<br>
<textarea type="text" name"content"></textarea>
</p>
<p><input type="hidden" name="cid" value="<?php echo $cid; ?>" ></p>
<p><input type="submit" name="submit" value="Create"></p>
</form>
I've been debugging this for many hours now. It doesnt seem to be passing the post informatoin through to the create-topic-parse from the form. I just keep getting the error message… which means it is getting a post value from submit :/ in order to get into the conditional branch.
Kind regards
— DevonLively
HeyIm creating a forum with php, javascript and mysql but i dispaly all data from the database on 1 page, I mean i never reload the webpage. If I want url links to all post on the forum how is that done? 🙁
I've gotten a problem with
Undefined variable: topics in C:xampphtdocsview_category.php on line 43 and line 43 looks like this $topics .= "<table width='100%' style='border-collapse: collapse;'>";
and 46 $topic .= "<tr><td colspan='3'><hr /></td><tr>";
This is my link: [create_topic_phrase is names as create_topic_create]
MYWEBSITE/create_topic_create.php?topic_title=&topic_content=&cid=2&topic_submit=<a+href%3D%27create_topic.php%3Fcid%3D%272%27><p>%7C+Click+here+to+create+a+topic.<%2Fp><%2Fa>
I'm getting this error "Column count doesn't match value count at row 1" and what can I do for fix this? Please, answer me…
Guys, at the view category, the create topic link is suppose to be :
<a href='create_topic.php?cid=$cid'><p>| Click here to create a topic.</p></a>";
Hey! I get this error when creating the topic. " You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') VALUES ('2','11','1','test',now())' at line 1
Remove the period from the first '$topics .=[…]' and change '$topic .=' to '$topics .='. 🙂
outdated to fuck and would throw shit loads of errors wouldn't even bother
Notice: Undefined variable: email in C:xampphtdocsComplete_Source_Codepost_reply_parse.php on line 58
Notice: Undefined variable: email in C:xampphtdocsComplete_Source_Codepost_reply_parse.php on line 58
hello i got this error:
Notice: Undefined variable: topics in C:xampphtdocsComplete_Source_Codeview_category.php on line 83
Notice: Undefined variable: topic in C:xampphtdocsComplete_Source_Codeview_category.php on line 86,
Notice: Undefined variable: userids in C:xampphtdocsComplete_Source_Codepost_reply_parse.php on line 39
Sorry I was not able to reply quick enough. I'm glad you figured it out.
Right now if you donate $6 or more to my PayPal account, admin(AT)timkipptutorials(DOT)com, I will send you a link to download the complete DVD series and code.
I found out the Error.. Hahahah I am happy now.
I forgot to add : post_creator after topic_id. I had 4 queries for 5 values.
$sql = "INSERT INTO posts (category_id, topic_id, post_content, post_date) VALUES ('".$cid."','".$tid."','".$creator."','".$reply_content."', now())";
Great Tutorial Tim.
Where can i buy the DVD or souce code?
Great Tutorial!
Getting this error: Column count doesn't match value count at row 1?
Help pleaz!
why dont you use if ( !isset($_SESSION[ 'uid ' ]) ) than setting the autoglobal session to null string?
Found it myself.. it was an Mysql Bug.. -.-
bugs. mysql. com/ bug .php ?id=1689
when trying to create a topic, i get the error:
Unknown column 'post_content' in 'field list'
.. any idea what it could be?
Incorrect integer value: '' for column 'category_id' at row 1
dose it say on the screen, whats wrong?
Do you know why my post_creator and topic_creator stays 0?
The w.ww is without the period and spaces
When it goes to create_topic_parse.php I get this error:
Notice: Undefined index: cid in D:wamp w.ww forumcreate_topic_parse.php on line 17
I've checked over the code several times but I can't find a solution
You could perform a query that would retrieve the username of the user based on the userID you pass into the query. Also, you can download the complete source code on my website in the Code Bank under the PHP/MySQL section.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE id='' LIMIT 1' at line 1
Any ideas?
header("Location: view_topic.php?cid=".$cid."&tid=".$new_topic_id.");
you forgot the ending quotation marks. you also need to make sure you are giving values to $cid, $tid, and $new_topic_id as I stated in the forums.
@timkipptutorials Okay thanks. Got that to work. What about undefined index? That seems to be another problem.
@JoeMcInformation at the top of your script you just need to declare the variable. put this line in your php:
$variable = "";
where "variable" is to be changed to whatever the variable name is.
@timkipptutorials how do you fix the undefined variable error? I know of the @ suppressor but actually want to fix it. Is there another option?
@Cageymartijn head over to my site and post your code in our forums and we will be able to help you further. It sounds like there is a problem in how you are coding out your header redirection.
I'm getting this error: Warning: Header may not contain more than a single header, new line detected. in F:USBwebserverrootpwsmaak_blog_parse.php on line 35
@jago125 Yeah when I made this tutorial series I was using a different server than what I normally use and it didn't throw the undefined variable error. I now make sure I check before running my scripts. Thanks for the feedback.
thanks looking forward to part 4 🙂