Jump to content

karimali831

Members
  • Posts

    436
  • Joined

  • Last visited

Everything posted by karimali831

  1. yes, I can use use both.
  2. Would you be able to help me out on this please? I'm not familar how to do this with PHP. If you take a look at the attatchment in my first post, I've explained why the streak should be 3. But not sure how to build this expression. I'm working on a ladder system project and I'm stuck on this bit (http://team-x1.co.uk/site/index.php?site=standings&ladderID=17) so any help at all, I'll be grateful.
  3. anyone can help please or must I re-phrase?
  4. Hi, This query will show match stats of a user, the query is the output in the attatchment. I want to calculate the streak if score1 is greater than score2. So basically, in the attatchment I have selected 3 rows, these 3 rows should be a 3 streak because the user won 3 matches in a row (according to date) SELECT * FROM webs_cup_matches WHERE ladID='17' AND (clan1 != '0' AND clan2 != '0') AND (clan1='2630' || clan2='2630') AND (clan1 != '2147483647' AND clan2 != '2147483647') ORDER BY date DESC any help appreciated. [attachment deleted by admin]
  5. Is this correct ? I hope $query = "SELECT COUNT(matchID) as streak, clan1 FROM webs_cup_matches WHERE ladID='$laddID' AND clan1='$teamID' AND score1 > score2 AND confirmscore='1' AND einspruch='0' GROUP BY clan1 DESC LIMIT 1 UNION SELECT COUNT(matchID) as streak, clan2 FROM webs_cup_matches WHERE ladID='$laddID' AND clan2='$teamID' AND score1 < score2 AND confirmscore='1' AND einspruch='0' GROUP BY clan2 ORDER BY streak DESC LIMIT 1"; $streak = mysql_query($query);
  6. I had an attempt at this but wasn't successful could you do this for me please?
  7. I am using two seperate queries to calculate a streak, but the queries must be grouped together to find the actual streak? Query 1: SELECT COUNT(matchID) as streak, clan1 FROM webs_cup_matches WHERE ladID='17' AND clan1='2630' AND score1 > score2 AND confirmscore='1' AND einspruch='0' GROUP BY clan1 ORDER BY streak DESC LIMIT 1 Query 2: SELECT COUNT(matchID) as streak, clan2 FROM webs_cup_matches WHERE ladID='17' AND clan2='2630' AND score1 < score2 AND confirmscore='1' AND einspruch='0' GROUP BY clan2 ORDER BY streak DESC LIMIT 1 is it possible someone can join these queries together?
  8. Yh I thought about what I could do, but nothing fits. Nothing more you can do, so thanks very much for your help! I'll try figure something around this...
  9. Hmm does that mean I can not use your method? It must be in loop for things to work in my script.
  10. Oh.. I just put echo array_sum($array)/count($array)."<br>"; right at the end of the page and it works perfect. I think it is because the script is in a loop itself?
  11. there is more as you can see I use $gap['clanID'] in query. It is a long file. Is this the reason then?
  12. so no ideas why it is producing other values ? this is your code saved: $query = mysql_query("SELECT SUM($score1) as wonpoints FROM ".PREFIX."cup_matches WHERE matchno='".$ID."' AND $score1 > $score2 AND ($alpha_groups) AND (clan1='".$gap['clanID']."' || clan2='".$gap['clanID']."')"); while( $row = mysql_fetch_assoc($query) ) { $array[] = $row['wonpoints']; } echo array_sum($array)/count($array)."<br>";
  13. it's wrong: $query = mysql_query("SELECT SUM($score1) as wonpoints FROM ".PREFIX."cup_matches WHERE matchno='".$ID."' AND $score1 > $score2 AND ($alpha_groups) AND (clan1='".$gap['clanID']."' || clan2='".$gap['clanID']."')"); while( $row = mysql_fetch_assoc($query) ) { $array[] = $row['wonpoints']; //echo $row['wonpoints'].","; } echo array_sum($array)/count($array)."<br>"; the echo outputs: 34 26.5 25 23 19.8 20.1666666667 18.4285714286 19 18.7777777778 20 20.0909090909 21.0833333333 20 20.6428571429 20.1333333333 19.3125 looks like the last value is correct, average value of all values in array. Not sure why it is giving me all these other values??
  14. Ok, is this right? $query = mysql_query("SELECT SUM($score1) as wonpoints FROM ".PREFIX."cup_matches WHERE matchno='".$ID."' AND $score1 > $score2 AND ($alpha_groups) AND (clan1='".$gap['clanID']."' || clan2='".$gap['clanID']."')"); while( $row = mysql_fetch_assoc($query) ) { $array[] = $row['wonpoints']; echo $row['wonpoints'].","; echo array_sum(explode(',', $array))/count(explode(',', $array)).","; } first echo 34,19,22,17,7,22,8,23,17,31,21,32,7,29,13,7, 2nd echo 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, now all I want is to get the average number of the first echo, which should be 19 dot...
  15. Thanks that worked great but what if $t was this... (it doesn't give the average value) $po=mysql_fetch_array(mysql_query("SELECT SUM($score1) as wonpoints FROM ".PREFIX."cup_matches WHERE matchno='".$ID."' AND $score1 > $score2 AND ($alpha_groups) AND (clan1='".$gap['clanID']."' || clan2='".$gap['clanID']."')")); echo $po['wonpoints']; //outputs 3419221772282317312132729137 echo $t =$po['wonpoints'].","; //outputs 34,19,22,17,7,22,8,23,17,31,21,32,7,29,13,7,
  16. Hi, I need help with this, I am quite new to arrays. This one works fine: echo array_sum(array(34,19,22,17,7,22,8,23,17,31,21,32,7,29,13,7))/count(array(34,19,22,17,7,22,8,23,17,31,21,32,7,29,13,7)); which gives "19..." it gets average number. What I want to put the values in the array in a variable so I do this: $t = "34,19,22,17,7,22,8,23,17,31,21,32,7,29,13,7"; so why can't I use array like this: echo array_sum(array($t))/count(array($t)); I need to use variable in array, please someone help.
  17. Please someone it's towards a project to which I should be releasing very soon...
  18. something like this... <?php $max = mysql_query("SELECT MAX(ART_ID) AS maxAID FROM Artisan"); if(!mysql_num_rows($max)) { echo "Artisan was not deleted."; } else { while($row=mysql_fetch_array($max)) { $ART_ID = $row['maxAID']; mysql_query ("DELETE FROM Artisan WHERE ART_ID = '$ART_ID'") or die(mysql_error()); mysql_query ("DELETE FROM ArtisanAnswer WHERE ART_ID = '$ART_ID'") or die(mysql_error()); echo "Row(s) successfully deleted!"; } } ?>
  19. Hi, Competitors vs. against each other and are recorded in a database. Each participant equally has 4 matches each, as you can see in the attatchment following the points gained in their played matches. I want to be able to determine the qualified participants according to either their "points" or "wins/losses". If two competitors have the same points, then I have already made a solution that another match must be generated for the two participants with the same points and draws can not be submitted which means the points will always be different for each team. I want to pick out half of participants 8/16 (screenshot below) with highest points which will be the qualifiers, or pick out half participants 8/16 with best match stats according to wins/losses. Any help I would be very grateful, thanks. [attachment deleted by admin]
  20. Hmm... I understand that but I need a method of getting rid of the BOM on every page. It has effected hundreds, is there some global thing I can use so that no BOM is included? something in .htaccess or phi.ini or anything?
  21. I managed to solve that but I have a problem with php header location. None of my headers location works.. it is blank?
  22. I solved it, I needed header('content-type: text/html; charset=utf-8'); at my index.php thank god for that!
  23. I don't think there is any problem with the code.. I changed the safe_query function in the below code, then noticed the layout change, reverted changes back but layout did not revert back. It's strange. <?php /* ########################################################################## # # # Version 4 / / / # # -----------__---/__---__------__----__---/---/- # # | /| / /___) / ) (_ ` / ) /___) / / # # _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___ # # Free Content / Management System # # / # # # # # # Copyright 2005-2010 by webspell.org # # # # visit webSPELL.org, webspell.info to get webSPELL for free # # - Script runs under the GNU GENERAL PUBLIC LICENSE # # - It's NOT allowed to remove this copyright-tag # # -- http://www.fsf.org/licensing/licenses/gpl.html # # # # Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at), # # Far Development by Development Team - webspell.org # # # # visit webspell.org # # # ########################################################################## */ // -- ERROR REPORTING -- // define('DEBUG', "ON"); error_reporting(0); // E_ALL = public mode, E_ALL = development-mode // -- SET ENCODING FOR MB-FUNCTIONS -- // mb_internal_encoding("UTF-8"); // -- SET HTTP ENCODING -- // header('content-type: text/html; charset=utf-8'); // -- CONNECTION TO MYSQL -- // mysql_connect($host, $user, $pwd) or system_error('ERROR: Can not connect to MySQL-Server'); mysql_select_db($db) or system_error('ERROR: Can not connect to database "'.$db.'"'); mysql_query("SET NAMES 'utf8'"); // -- GENERAL PROTECTIONS -- // function globalskiller() { // kills all non-system variables $global = array('GLOBALS', '_POST', '_GET', '_COOKIE', '_FILES', '_SERVER', '_ENV', '_REQUEST', '_SESSION'); foreach ($GLOBALS as $key=>$val) { if(!in_array($key, $global)) { if(is_array($val)) unset_array($GLOBALS[$key]); else unset($GLOBALS[$key]); } } } function unset_array($array) { foreach($array as $key) { if(is_array($key)) unset_array($key); else unset($key); } } globalskiller(); if(isset($_GET['site'])) $site=$_GET['site']; else $site= null; if($site!="search") { $request=strtolower(urldecode($_SERVER['QUERY_STRING'])); $protarray=array("union","select","into","where","update ","from","/*","set ",PREFIX."user ",PREFIX."user(",PREFIX."user`",PREFIX."user_groups","phpinfo", "escapeshellarg","exec","fopen","fwrite","escapeshellcmd","passthru","proc_close","proc_get_status","proc_nice", "proc_open","proc_terminate","shell_exec","system","telnet","ssh","cmd","mv","chmod","chdir","locate","killall", "passwd","kill","script","bash","perl","mysql","~root",".history","~nobody","getenv" ); $check=str_replace($protarray, '*', $request); if($request != $check) system_error("Invalid request detected."); } function security_slashes(&$array) { foreach($array as $key => $value) { if(is_array($array[$key])) { security_slashes($array[$key]); } else { if(get_magic_quotes_gpc()) { $tmp = stripslashes($value); } else { $tmp = $value; } if(function_exists("mysql_real_escape_string")) { $array[$key] = mysql_real_escape_string($tmp); } else { $array[$key] = addslashes($tmp); } unset($tmp); } } } security_slashes($_POST); security_slashes($_COOKIE); security_slashes($_GET); security_slashes($_REQUEST); // -- MYSQL QUERY FUNCTION -- // $_mysql_querys = array(); function safe_query($query="") { global $_mysql_querys; if(stristr(str_replace(' ', '', $query), "unionselect")===FALSE AND stristr(str_replace(' ', '', $query), "union(select")===FALSE){ $_mysql_querys[] = $query; if(empty($query)) return false; if(DEBUG == "OFF") $result = mysql_query($query) or die('Query failed!'); else { $result = mysql_query($query) or die('Query failed: ' .'<li>errorno='.mysql_errno() .'<li>error='.mysql_error() .'<li>query='.$query); } return $result; } else die(); } // -- SYSTEM ERROR DISPLAY -- // function system_error($text,$system=1) { if($system) { include('version.php'); $info='webSPELL Version: '.$version.'<br />PHP Version: '.phpversion().'<br />MySQL Version: '.mysql_get_server_info().'<br />'; } else { $info = ''; } die('<!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="description" content="Clanpage using webSPELL 4 CMS" /> <meta name="author" content="webspell.org" /> <meta name="keywords" content="webspell, webspell4, clan, cms" /> <meta name="copyright" content="Copyright © 2005 - 2009 by webspell.org" /> <meta name="generator" content="webSPELL" /> <title>webSPELL</title> </head> <body> <center> <table border="0" cellpadding="1" cellspacing="1" bgcolor="#eeeeee"> <tr> <td><a href="http://www.webspell.org" target="_blank"><img src="images/banner.gif" style="border:none;" alt="webSPELL.org" title="webSPELL.org" /></a></td> </tr> <tr bgcolor="#ffffff"> <td><div style="color:#333333;font-family:Tahoma,Verdana,Arial;font-size:11px;padding:5px;">'.$info.'<br /><font color="red">'.$text.'</font><br /> </div></td> </tr> <tr bgcolor="#ffffff"> <td><div style="color:#333333;font-family:Tahoma,Verdana,Arial;font-size:11px;padding:5px;">For support visit <a href="http://webspell.org" target="_blank">webspell.org</a></div></td> </tr> </table> </center> </body> </html>'); } // -- SYSTEM FILE INCLUDE -- // function systeminc($file) { if(!include('src/'.$file.'.php')) system_error('Could not get system file for '.$file); } // -- IGNORED USERS -- // function isignored($userID, $buddy) { $anz=mysql_num_rows(safe_query("SELECT userID FROM ".PREFIX."buddys WHERE buddy='$buddy' AND userID='$userID' ")); if($anz) { $ergebnis=safe_query("SELECT * FROM ".PREFIX."buddys WHERE buddy='$buddy' AND userID='$userID' "); $ds=mysql_fetch_array($ergebnis); if($ds['banned']==1) return 1; else return 0; } else return 0; } // -- GLOBAL SETTINGS -- // $ds = mysql_fetch_array(safe_query("SELECT * FROM ".PREFIX."settings")); $maxshownnews = $ds['news']; if(empty($maxshownnews)) $maxshownnews = 10; $maxnewsarchiv = $ds['newsarchiv']; if(empty($maxnewsarchiv)) $maxnewsarchiv = 20; $maxheadlines = $ds['headlines']; if(empty($maxheadlines)) $maxheadlines = 10; $maxheadlinechars = $ds['headlineschars']; if(empty($maxheadlinechars)) $maxheadlinechars = 18; $maxtopnewschars = $ds['topnewschars']; if(empty($maxtopnewschars)) $maxtopnewschars = 200; $maxarticles = $ds['articles']; if(empty($maxarticles)) $maxarticles = 20; $latestarticles = $ds['latestarticles']; if(empty($latestarticles)) $latestarticles = 5; $articleschars = $ds['articleschars']; if(empty($articleschars)) $articleschars = 18; $maxclanwars = $ds['clanwars']; if(empty($maxclanwars)) $maxclanwars = 20; $maxresults = $ds['results']; if(empty($maxresults)) $maxresults = 5; $maxupcoming = $ds['upcoming']; if(empty($maxupcoming)) $maxupcoming = 5; $maxguestbook = $ds['guestbook']; if(empty($maxguestbook)) $maxguestbook = 20; $maxshoutbox = $ds['shoutbox']; if(empty($maxshoutbox)) $maxshoutbox = 5; $maxsball = $ds['sball']; if(empty($latestarticles)) $latestarticles = 5; $sbrefresh = $ds['sbrefresh']; if(empty($sbrefresh)) $sbrefresh = 60; $maxtopics = $ds['topics']; if(empty($maxtopics)) $maxtopics = 20; $maxposts = $ds['posts']; if(empty($maxposts)) $maxposts = 10; $maxlatesttopics = $ds['latesttopics']; if(empty($maxlatesttopics)) $maxlatesttopics = 10; $maxlatesttopicchars = $ds['latesttopicchars']; if(empty($maxlatesttopicchars)) $maxlatesttopicchars = 18; $maxfeedback = $ds['feedback']; if(empty($maxfeedback)) $maxfeedback = 5; $maxmessages = $ds['messages']; if(empty($maxmessages)) $maxmessages = 5; $maxusers = $ds['users']; if(empty($maxusers)) $maxusers = 5; $hp_url = $ds['hpurl']; $admin_name = $ds['adminname']; $admin_email = $ds['adminemail']; $myclantag = $ds['clantag']; $myclanname = $ds['clanname']; $maxarticles = $ds['articles']; if(empty($maxarticles)) $maxarticles = 5; $maxawards = $ds['awards']; if(empty($maxawards)) $maxawards = 20; $maxdemos = $ds['demos']; if(empty($maxdemos)) $maxdemos = 20; $profilelast = $ds['profilelast']; if(empty($profilelast)) $profilelast = 20; $topnewsID = $ds['topnewsID']; $sessionduration = $ds['sessionduration']; if(empty($sessionduration)) $sessionduration = 24; $closed = (int)$ds['closed']; $gb_info = $ds['gb_info']; $imprint_type = $ds['imprint']; $picsize_l = $ds['picsize_l']; if(empty($picsize_l)) $picsize_l = 9999; $picsize_h = $ds['picsize_h']; if(empty($picsize_h)) $picsize_h = 9999; $gallerypictures = $ds['pictures']; $publicadmin = $ds['publicadmin']; $thumbwidth = $ds['thumbwidth']; if(empty($thumbwidth)) $thumbwidth = 120; $usergalleries = $ds['usergalleries']; $maxusergalleries = $ds['maxusergalleries']; $default_language = $ds['default_language']; if(empty($default_language)) $default_language = 'uk'; $rss_default_language = $ds['default_language']; if(empty($rss_default_language)) $rss_default_language = 'uk'; $search_min_len = $ds['search_min_len']; if(empty($search_min_len)) $search_min_len = '4'; $autoresize = $ds['autoresize']; if(!isset($autoresize)) $autoresize = 2; $max_wrong_pw = $ds['max_wrong_pw']; if(empty($max_wrong_pw)) $max_wrong_pw = 3; $lastBanCheck = $ds['bancheck']; $insertlinks = $ds['insertlinks']; $new_chmod = 0666; // -- STYLES -- // $ergebnis=safe_query("SELECT * FROM ".PREFIX."styles"); $ds=mysql_fetch_array($ergebnis); define('PAGEBG', $ds['bgpage']); define('BORDER', $ds['border']); define('BGHEAD', $ds['bghead']); define('BGCAT', $ds['bgcat']); define('BG_1', $ds['bg1']); define('BG_2', $ds['bg2']); define('BG_3', $ds['bg3']); define('BG_4', $ds['bg4']); $hp_title = stripslashes($ds['title']); $pagebg = PAGEBG; $border = BORDER; $bghead = BGHEAD; $bgcat = BGCAT; $wincolor = $ds['win']; $loosecolor = $ds['loose']; $drawcolor = $ds['draw']; ?>
  24. Can the byte order mark have an effect on the stylesheet? I was editing a php file and as soon as I saved it, the entire layout of my website was distorted, well in IE, but both browsers the font size has increased I have never came across something like this in years. I think I changed the encoding but it may of placed a BOM on every page. I have no idea how to rectify this... anyhelp would be nice! http://team-x1.co.uk/site/
×
×
  • 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.