Jump to content

ewok13

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ewok13's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi. Im trying to make a PHP code that will find the average number. What I want is, a lot of input fields where you can write a number in. Then my code should take these numbers and divide them with the amount of input fields that has been written in. So that some fields you don't have to write a number, and the code will still give you a correct average. My code so far: <?php if (isset($_POST['calc'])) { $m=$_POST['mat']; $e=$_POST['da']; $s=$_POST['eng']; $f=$_POST['fys']; $h=$_POST['bio']; $p=$_POST['geo']; $ave=($m+$e+$s+$f+$h+$p)/; } ?> <a href="" onclick="return hs.htmlExpand(this, { headingText: 'Beregn dit Gennemsnit:' })"> <b>Beregn dit Gennemsnit: <?php echo $ave;?></b><br></br> </a> <div class="highslide-maincontent"> <form id="gennemsnit" name="form1" method="post" action=""> Matematik<input name="math" type="text" id="mat" size="3" maxlength="4" /><br /> Dansk<input name="eng" type="text" id="da" size="3" maxlength="4" /><br /> Engelsk<input name="sci" type="text" id="eng" size="3" maxlength="4" /><br /> Fysik<input name="fil" type="text" id="fys" size="3" maxlength="4" /><br /> Biologi<input name="he" type="text" id="bio" size="3" maxlength="4" /><br /> Geografi<input name="pe" type="text" id="geo" size="3" maxlength="4" /></td><br /> <input name="calc" type="submit" id="calc" value="Beregn"/><br /><br /> </form> What I need is the code of how to divide with the amount of input fields that has been written in. Thx for any help
  2. What I meant was, I search for something in my form, then some result will appear on the same page. I need these results to dissappear again, when I refresh the page of my website. So that I can make a new search without having the old search on the page.
  3. Hi. Im making a simple search for my website, and I want to know what I can do to remove the results I get from the search? I want it to be removed when updating the page and when going to another page and returning it also has to be removed. Here is the code: <b>Anvend vores søgemaskine og find din uddannelse:</b><br></br> <form action="inspiration.php" method="post"> <input type="text" name="uddannelse" /> <input type="submit" name="submit" value="Søg" /> </form> <b> <?php mysql_connect ("localhost", "root","") or die (mysql_error()); mysql_select_db ("forum"); $uddannelse = $_POST['uddannelse']; $sql = mysql_query("select * from uddannelser where uddannelse like '%$uddannelse%'"); while ($row = mysql_fetch_array($sql)){ echo '<br/>'.$row['uddannelse']; ?></b> <b><?php echo '<br/><br/> Hvad er '.$row['uddannelse'];?></b><br></br><?php echo ''.$row['info'];?> <b><?php echo '<br/><br/> Læs mere om '.$row['uddannelse'];?></b><br></br><?php echo '' .$row['fakta'];} $anymatches=mysql_num_rows($sql); if ($anymatches == 0) { echo "Der er desværre ingen uddannelse der passer til din søgning<br><br>"; } ?>
  4. 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
  5. 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>
  6. 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
  7. It doesn't say. That is all it says. But I would think it is the code at line 83-84.
  8. 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?
  9. I did what you said, but nothing happens, it just goes all white.
  10. 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
×
×
  • 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.