ewok13 Posted April 21, 2012 Share Posted April 21, 2012 Hi all.. I got a problem with my forum. It connects correctly to the database, and it can find the tables. Though after the registration and creating a category, the problem starts. Cause when you go into the category that I created and creates a new topic, it won't create it cause it can't find the category that I want to create a topic in. Some how it wont check what has been created in the category table. All this works perfectly, if I run it in a localhost, but not on a server. Here is the website: euctester.dk/mikkelsen Here is the code for the creating a new topic: <?php //Denne side lader brugerne oprette nye emner include('config.php'); if(isset($_GET['parent'])) { $id = intval($_GET['parent']); if(isset($_SESSION['username'])) { $dn1 = mysql_fetch_array(mysql_query('select count(c.id) as nb1, c.name from categories as c where c.id="'.$id.'"')); if($dn1['nb1']>0) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" /> <title>New Topic - <?php echo htmlentities($dn1['name'], ENT_QUOTES, 'UTF-8'); ?></title> <script type="text/javascript" src="functions.js"></script> <link rel="icon" href="design/images/favicon.ico" type="image/png" /> <link rel="shortcut icon" href="design/images/favicon.ico" /> </head> <body> <div class="baggrund"> <div class="header"> <a href="forum.php" style="text-decoration:none"> <div class="overskrift"><span style="color:#000">Forum</span> </div> </a> <ul id="top-nav"> <li><a href="index.php" id="forsidenav">Forside</a></li> <?php if(isset($_SESSION['username']) && $_SESSION['username']!="") { echo("<li><a href='login.php'>Log Ud</a></li>"); } else { echo("<li><a href='login.php'>Log Ind</a></li>"); } ?> <li><a href="hjalp.php" id="hjalpenav">Hjælp</a></li> </ul> </div> <div class="content"> <?php $nb_new_pm = mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"')); $nb_new_pm = $nb_new_pm['nb_new_pm']; ?> <div class="box"> <div class="box_left"> <a href="<?php echo $url_home; ?>">Forum Index</a> > <a href="list_topics.php?parent=<?php echo $id; ?>"><?php echo htmlentities($dn1['name'], ENT_QUOTES, 'UTF-8'); ?></a> > Nyt Emne</div> <div class="box_right"> <a href="list_pm.php">Dine Beskeder(<?php echo $nb_new_pm; ?>)</a> - <a href="profile.php?id=<?php echo $_SESSION['userid']; ?>"><?php echo htmlentities($_SESSION['username'], ENT_QUOTES, 'UTF-8'); ?></a> (<a href="login.php">Log Ud</a>) </div> <div class="clean"></div> </div> <?php if(isset($_POST['message'], $_POST['title']) and $_POST['message']!='' and $_POST['title']!='') { include('bbcode_function.php'); $title = $_POST['title']; $message = $_POST['message']; if(get_magic_quotes_gpc()) { $title = stripslashes($title); $message = stripslashes($message); } $title = mysql_real_escape_string($title); $message = mysql_real_escape_string(bbcode_to_html($message)); if(mysql_query('insert into topics (parent, id, id2, title, message, authorid, timestamp, timestamp2) select "'.$id.'", ifnull(max(id), 0)+1, "1", "'.$title.'", "'.$message.'", "'.$_SESSION['userid'].'", "'.time().'", "'.time().'" from topics')) { ?> <div class="message">Emnet er blevet oprettet.<br /> <a href="list_topics.php?parent=<?php echo $id; ?>">Gå til forumet</a></div> <?php } else { echo 'Der opstod en fejl under oprettelsen emnet.'; } } else { ?> <form action="new_topic.php?parent=<?php echo $id; ?>" method="get"> <label for="title">Titel</label><input type="text" name="title" id="title" /><br /> <label for="message">Besked</label><br /> <div class="message_buttons"> <input type="button" value="Fed" onclick="javascript:insert('[b]', '[/b]', 'message');" /><!-- --><input type="button" value="Skrå" onclick="javascript:insert('[i]', '[/i]', 'message');" /><!-- --><input type="button" value="Understreg" onclick="javascript:insert('[u]', '[/u]', 'message');" /><!-- --><input type="button" value="Billede" onclick="javascript:insert('[img=', ']', 'message');" /><!-- --><input type="button" value="Link" onclick="javascript:insert('[url]', '[/url]', 'message');" /><!-- --><input type="button" value="Venstre" onclick="javascript:insert(' [left]', '[/left] ', 'message');" /><!-- --><input type="button" value="Center" onclick="javascript:insert(' [center]', '[/center] ', 'message');" /><!-- --><input type="button" value="Højre" onclick="javascript:insert(' [right]', '[/right] ', 'message');" /> </div> <textarea name="message" id="message" cols="70" rows="6"></textarea><br /> <input type="submit" value="Send" /> </form> <?php } ?> </div> </div> </body> </html> <?php } else { echo '<h2>Den kategori, som du ønsker at tilføje et emne, findes ikke.</h2>'; } } else { ?> <h2>Du skal være logget ind for at have adgang til denne side:</h2> <div class="box_login"> <form action="login.php" method="post"> <label for="username">Brugernavn</label><input type="text" name="username" id="username" /><br /> <label for="password">Kodeord</label><input type="password" name="password" id="password" /><br /> <label for="memorize">Husk</label><input type="checkbox" name="memorize" id="memorize" value="yes" /> <div class="center"> <input type="submit" value="Log Ind" /> <input type="button" onclick="javascript:document.location='signup.php';" value="Registrer" /> </div> </form> </div> <?php } } else { echo '<h2>ID´et for den kategori, du ønsker at tilføje et emne er ikke defineret.</h2>'; } ?> BTW. Sry that the website is in danish Quote Link to comment https://forums.phpfreaks.com/topic/261383-php-forum-problem/ Share on other sites More sharing options...
MMDE Posted April 21, 2012 Share Posted April 21, 2012 It being in danish is totally okay for me (even though I can't understand what you say, I can read Danish just fine). Before every line with mysql_query() in it add a line before it with the same input into the mysql_query() function and add this at the end: or die(mysql_error()); For example line 80 looks like this: if(mysql_query('insert into topics (parent, id, id2, title, message, authorid, timestamp, timestamp2) select "'.$id.'", ifnull(max(id), 0)+1, "1", "'.$title.'", "'.$message.'", "'.$_SESSION['userid'].'", "'.time().'", "'.time().'" from topics')) Make it look like this instead: mysql_query('insert into topics (parent, id, id2, title, message, authorid, timestamp, timestamp2) select "'.$id.'", ifnull(max(id), 0)+1, "1", "'.$title.'", "'.$message.'", "'.$_SESSION['userid'].'", "'.time().'", "'.time().'" from topics') or die(mysql_error()); if(mysql_query('insert into topics (parent, id, id2, title, message, authorid, timestamp, timestamp2) select "'.$id.'", ifnull(max(id), 0)+1, "1", "'.$title.'", "'.$message.'", "'.$_SESSION['userid'].'", "'.time().'", "'.time().'" from topics')) Why you may wonder? It is so that if there is anything wrong with your mysql queries it will tell you what it is. Quote Link to comment https://forums.phpfreaks.com/topic/261383-php-forum-problem/#findComment-1339427 Share on other sites More sharing options...
ewok13 Posted April 22, 2012 Author Share Posted April 22, 2012 I did what you said, but nothing happens, it just goes all white. Quote Link to comment https://forums.phpfreaks.com/topic/261383-php-forum-problem/#findComment-1339504 Share on other sites More sharing options...
MMDE Posted April 22, 2012 Share Posted April 22, 2012 I did what you said, but nothing happens, it just goes all white. Are you sure you did it correctly? I've done it for you here, and also turned on error reporting: <?php error_reporting(E_ALL); //Denne side lader brugerne oprette nye emner include('config.php'); if(isset($_GET['parent'])) { $id = intval($_GET['parent']); if(isset($_SESSION['username'])) { mysql_query('select count(c.id) as nb1, c.name from categories as c where c.id="'.$id.'"') or die(mysql_error()); $dn1 = mysql_fetch_array(mysql_query('select count(c.id) as nb1, c.name from categories as c where c.id="'.$id.'"')); if($dn1['nb1']>0) { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" /> <title>New Topic - <?php echo htmlentities($dn1['name'], ENT_QUOTES, 'UTF-8'); ?></title> <script type="text/javascript" src="functions.js"></script> <link rel="icon" href="design/images/favicon.ico" type="image/png" /> <link rel="shortcut icon" href="design/images/favicon.ico" /> </head> <body> <div class="baggrund"> <div class="header"> <a href="forum.php" style="text-decoration:none"> <div class="overskrift"><span style="color:#000">Forum</span> </div> </a> <ul id="top-nav"> <li><a href="index.php" id="forsidenav">Forside</a></li> <?php if(isset($_SESSION['username']) && $_SESSION['username']!="") { echo("<li><a href='login.php'>Log Ud</a></li>"); } else { echo("<li><a href='login.php'>Log Ind</a></li>"); } ?> <li><a href="hjalp.php" id="hjalpenav">Hjælp</a></li> </ul> </div> <div class="content"> <?php mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"') or die(mysql_error()); $nb_new_pm = mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"')); $nb_new_pm = $nb_new_pm['nb_new_pm']; ?> <div class="box"> <div class="box_left"> <a href="<?php echo $url_home; ?>">Forum Index</a> > <a href="list_topics.php?parent=<?php echo $id; ?>"><?php echo htmlentities($dn1['name'], ENT_QUOTES, 'UTF-8'); ?></a> > Nyt Emne</div> <div class="box_right"> <a href="list_pm.php">Dine Beskeder(<?php echo $nb_new_pm; ?>)</a> - <a href="profile.php?id=<?php echo $_SESSION['userid']; ?>"><?php echo htmlentities($_SESSION['username'], ENT_QUOTES, 'UTF-8'); ?></a> (<a href="login.php">Log Ud</a>) </div> <div class="clean"></div> </div> <?php if(isset($_POST['message'], $_POST['title']) and $_POST['message']!='' and $_POST['title']!='') { include('bbcode_function.php'); $title = $_POST['title']; $message = $_POST['message']; if(get_magic_quotes_gpc()) { $title = stripslashes($title); $message = stripslashes($message); } $title = mysql_real_escape_string($title); $message = mysql_real_escape_string(bbcode_to_html($message)); mysql_query('insert into topics (parent, id, id2, title, message, authorid, timestamp, timestamp2) select "'.$id.'", ifnull(max(id), 0)+1, "1", "'.$title.'", "'.$message.'", "'.$_SESSION['userid'].'", "'.time().'", "'.time().'" from topics') or die(mysql_error()); if(mysql_query('insert into topics (parent, id, id2, title, message, authorid, timestamp, timestamp2) select "'.$id.'", ifnull(max(id), 0)+1, "1", "'.$title.'", "'.$message.'", "'.$_SESSION['userid'].'", "'.time().'", "'.time().'" from topics')) { ?> <div class="message">Emnet er blevet oprettet.<br /> <a href="list_topics.php?parent=<?php echo $id; ?>">Gå til forumet</a></div> <?php } else { echo 'Der opstod en fejl under oprettelsen emnet.'; } } else { ?> <form action="new_topic.php?parent=<?php echo $id; ?>" method="get"> <label for="title">Titel</label><input type="text" name="title" id="title" /><br /> <label for="message">Besked</label><br /> <div class="message_buttons"> <input type="button" value="Fed" onclick="javascript:insert('[b]', '[/b]', 'message');" /><!-- --><input type="button" value="Skrå" onclick="javascript:insert('[i]', '[/i]', 'message');" /><!-- --><input type="button" value="Understreg" onclick="javascript:insert('[u]', '[/u]', 'message');" /><!-- --><input type="button" value="Billede" onclick="javascript:insert('[img=', ']', 'message');" /><!-- --><input type="button" value="Link" onclick="javascript:insert('[url]', '[/url]', 'message');" /><!-- --><input type="button" value="Venstre" onclick="javascript:insert(' [left]', '[/left] ', 'message');" /><!-- --><input type="button" value="Center" onclick="javascript:insert(' [center]', '[/center] ', 'message');" /><!-- --><input type="button" value="Højre" onclick="javascript:insert(' [right]', '[/right] ', 'message');" /> </div> <textarea name="message" id="message" cols="70" rows="6"></textarea><br /> <input type="submit" value="Send" /> </form> <?php } ?> </div> </div> </body> </html> <?php } else { echo '<h2>Den kategori, som du ønsker at tilføje et emne, findes ikke.</h2>'; } } else { ?> <h2>Du skal være logget ind for at have adgang til denne side:</h2> <div class="box_login"> <form action="login.php" method="post"> <label for="username">Brugernavn</label><input type="text" name="username" id="username" /><br /> <label for="password">Kodeord</label><input type="password" name="password" id="password" /><br /> <label for="memorize">Husk</label><input type="checkbox" name="memorize" id="memorize" value="yes" /> <div class="center"> <input type="submit" value="Log Ind" /> <input type="button" onclick="javascript:document.location='signup.php';" value="Registrer" /> </div> </form> </div> <?php } } else { echo '<h2>ID´et for den kategori, du ønsker at tilføje et emne er ikke defineret.</h2>'; } ?> If it shows up blank, try to check the page source (the html code), because it might be hiding because of some errors in the html or something. Might also be this is not the page with the error. Could be in one of the pages the form data gets sent to, and those are new_topic.php and login.php. I doubt it's the login.php page, but maybe new_topic.php? In any case, test the above code first! Quote Link to comment https://forums.phpfreaks.com/topic/261383-php-forum-problem/#findComment-1339558 Share on other sites More sharing options...
ewok13 Posted April 22, 2012 Author Share Posted April 22, 2012 Okay, now I get an error: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause What could that be? Quote Link to comment https://forums.phpfreaks.com/topic/261383-php-forum-problem/#findComment-1339561 Share on other sites More sharing options...
MMDE Posted April 22, 2012 Share Posted April 22, 2012 Okay, now I get an error: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause What could that be? What line number was it? Quote Link to comment https://forums.phpfreaks.com/topic/261383-php-forum-problem/#findComment-1339564 Share on other sites More sharing options...
ewok13 Posted April 22, 2012 Author Share Posted April 22, 2012 It doesn't say. That is all it says. But I would think it is the code at line 83-84. Quote Link to comment https://forums.phpfreaks.com/topic/261383-php-forum-problem/#findComment-1339566 Share on other sites More sharing options...
MMDE Posted April 22, 2012 Share Posted April 22, 2012 It doesn't say. That is all it says. But I would think it is the code at line 83-84. I'm thinking that's the one query it can't be, because it contains no grouping functions. I'm not an expert on mysql, so it would be nice to know what query it is that gives this error. Try to do this instead (see what I did inside the die function): mysql_query('select count(c.id) as nb1, c.name from categories as c where c.id="'.$id.'"') or die('Line: ' . __LINE__ . ', mysql error: ' . mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/261383-php-forum-problem/#findComment-1339568 Share on other sites More sharing options...
ewok13 Posted April 22, 2012 Author Share Posted April 22, 2012 Okay, now I get this: Line: 10, mysql error: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause Quote Link to comment https://forums.phpfreaks.com/topic/261383-php-forum-problem/#findComment-1339572 Share on other sites More sharing options...
MMDE Posted April 22, 2012 Share Posted April 22, 2012 Okay, now I get this: Line: 10, mysql error: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause Try to replace the mysql query in line 10 and 11 with this: mysql_query('select count(c.id) as nb1, c.name from categories as c where c.id="'.$id.'" GROUP BY c.id') Quote Link to comment https://forums.phpfreaks.com/topic/261383-php-forum-problem/#findComment-1339584 Share on other sites More sharing options...
ewok13 Posted April 22, 2012 Author Share Posted April 22, 2012 Now it works perfectly with the making new topics. Thx you so much Now the other problem I got is the sending pm to a user. It says the user does not exist. Here is the code to the send pm: <?php //Denne side lader dig oprette en ny personlig besked include('config.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" /> <title>Ny PM</title> <link rel="icon" href="design/images/favicon.ico" type="image/png" /> <link rel="shortcut icon" href="design/images/favicon.ico" /> </head> <body> <div class="baggrund"> <div class="header"> <a href="forum.php" style="text-decoration:none"> <div class="overskrift"><span style="color:#000">Forum</span> </div> </a> <ul id="top-nav"> <li><a href="index.php" id="forsidenav">Forside</a></li> <?php if(isset($_SESSION['username']) && $_SESSION['username']!="") { echo("<li><a href='login.php'>Log Ud</a></li>"); } else { echo("<li><a href='login.php'>Log Ind</a></li>"); } ?> <li><a href="hjalp.php" id="hjalpenav">Hjælp</a></li> </ul> </div> <?php if(isset($_SESSION['username'])) { $form = true; $otitle = ''; $orecip = ''; $omessage = ''; if(isset($_POST['title'], $_POST['recip'], $_POST['message'])) { $otitle = $_POST['title']; $orecip = $_POST['recip']; $omessage = $_POST['message']; if(get_magic_quotes_gpc()) { $otitle = stripslashes($otitle); $orecip = stripslashes($orecip); $omessage = stripslashes($omessage); } if($_POST['title']!='' and $_POST['recip']!='' and $_POST['message']!='') { $title = mysql_real_escape_string($otitle); $recip = mysql_real_escape_string($orecip); $message = mysql_real_escape_string(nl2br(htmlentities($omessage, ENT_QUOTES, 'UTF-8'))); $dn1 = mysql_fetch_array(mysql_query('select count(id) as recip, id as recipid, (select count(*) from pm) as npm from users where username="'.$recip.'"')); if($dn1['recip']==1) { if($dn1['recipid']!=$_SESSION['userid']) { $id = $dn1['npm']+1; if(mysql_query('insert into pm (id, id2, title, user1, user2, message, timestamp, user1read, user2read)values("'.$id.'", "1", "'.$title.'", "'.$_SESSION['userid'].'", "'.$dn1['recipid'].'", "'.$message.'", "'.time().'", "yes", "no")')) { ?> <div class="message">Din PM er blevet sendt.<br /> <a href="list_pm.php">Liste over dine Personlige Beskeder</a></div> <?php $form = false; } else { $error = 'En fejl opstod under afsendelsen af din besked.'; } } else { $error = 'Du kan ikke sende en besked til dig selv.'; } } else { $error = 'Modtageren af din PM findes ikke.'; } } else { $error = 'Et felt er ikke udfyldt'; } } elseif(isset($_GET['recip'])) { $orecip = $_GET['recip']; } if($form) { if(isset($error)) { echo '<div class="message">'.$error.'</div>'; } ?> <div class="content"> <?php $nb_new_pm = mysql_fetch_array(mysql_query('select count(*) as nb_new_pm from pm where ((user1="'.$_SESSION['userid'].'" and user1read="no") or (user2="'.$_SESSION['userid'].'" and user2read="no")) and id2="1"')); $nb_new_pm = $nb_new_pm['nb_new_pm']; ?> <div class="box"> <div class="box_left"> <a href="<?php echo $url_home; ?>">Forum Index</a> > <a href="list_pm.php">Liste over dine PM's</a> > Ny PM </div> <div class="box_right"> <a href="list_pm.php">Dine Beskeder(<?php echo $nb_new_pm; ?>)</a> - <a href="profile.php?id=<?php echo $_SESSION['userid']; ?>"><?php echo htmlentities($_SESSION['username'], ENT_QUOTES, 'UTF-8'); ?></a> (<a href="login.php">Log Ud</a>) </div> <div class="clean"></div> </div> <form action="new_pm.php" method="post"> Udfyld denne form for at sende en PM:<br /> <label for="title">Titel</label><input type="text" value="<?php echo htmlentities($otitle, ENT_QUOTES, 'UTF-8'); ?>" id="title" name="title" /><br /> <label for="recip">Modtager<span class="small">(Brugernavn)</span></label><input type="text" value="<?php echo htmlentities($orecip, ENT_QUOTES, 'UTF-8'); ?>" id="recip" name="recip" /><br /> <label for="message">Besked</label><textarea cols="40" rows="5" id="message" name="message"><?php echo htmlentities($omessage, ENT_QUOTES, 'UTF-8'); ?></textarea><br /> <input type="submit" value="Send" /> </form> </div> <?php } } else { ?> <div class="message">Du skal være logget ind for at have adgang til denne side.</div> <div class="box_login"> <form action="login.php" method="post"> <label for="username">Brugernavn</label><input type="text" name="username" id="username" /><br /> <label for="password">Kodeord</label><input type="password" name="password" id="password" /><br /> <label for="memorize">Husk</label><input type="checkbox" name="memorize" id="memorize" value="yes" /> <div class="center"> <input type="submit" value="Log Ind" /> <input type="button" onclick="javascript:document.location='signup.php';" value="Registrer" /> </div> </form> </div> <?php } ?> </div> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/261383-php-forum-problem/#findComment-1339607 Share on other sites More sharing options...
ewok13 Posted April 22, 2012 Author Share Posted April 22, 2012 Im getting this error: Line: 72, mysql error: Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause Quote Link to comment https://forums.phpfreaks.com/topic/261383-php-forum-problem/#findComment-1339631 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.