150 credits to debug

supajason

Member
Messages
288
Reaction score
2
Points
18
ooops forgot:

PHP:
$x = @mysql_connect($server,$dbuser,$dbpass);
@mysql_select_db($dbname,$x);

anything?
 

supajason

Member
Messages
288
Reaction score
2
Points
18
ok make a new php file and try this:

PHP:
<?php

$c = mysql_connect("host","user","pass");
if (!$c)
  {
  die('Could not connect: ' . mysql_error());
  }
else
  {
  echo "I Connected";
  }

$db = mysql_select_db("database", $c);

if (!$db)
  {
  die ("Cant Select : " . mysql_error());
  }
else
  {
  echo "Im Connected and selected";
  }


mysql_close($c);
?>
 

supajason

Member
Messages
288
Reaction score
2
Points
18
no just create it as a blank file fillout the information in it and the view it?
 

supajason

Member
Messages
288
Reaction score
2
Points
18
try this:

PHP:
<?


/*
Dynamic Star Rating Redux
Developed by Jordan Boesch
www.boedesign.com
Licensed under Creative Commons - http://creativecommons.org/licenses/by-nc-nd/2.5/ca/

Used CSS from komodomedia.com.
*/






$c = mysql_connect("mysql.x10hosting","viggeswe_vigswe","*my password*");
if (!$c)
  {
  die('Could not connect: ' . mysql_error());
  }

$db = mysql_select_db("viggeswe_phpbb", $c);

if (!$db)
  {
  die ("Cant Select : " . mysql_error());
  }



function getRating($id){

    $total = 0;
    $rows = 0;
    
    $sel = mysql_query("SELECT rating_num FROM ratings WHERE rating_id = '$id'");
    if(mysql_num_rows($sel) > 0){
    
        while($data = mysql_fetch_assoc($sel)){
        
            $total = $total + $data['rating_num'];
            $rows++;
        }
        
        $perc = ($total/$rows) * 20;
        
        //$newPerc = round($perc/5)*5;
        //return $newPerc.'%';
        
        $newPerc = round($perc,2);
        return $newPerc.'%';
    
    } else {
    
        return '0%';
    
    }
}

function outOfFive($id){

    $total = 0;
    $rows = 0;
    
    $sel = mysql_query("SELECT rating_num FROM ratings WHERE rating_id = '$id'");
    if(mysql_num_rows($sel) > 0){
    
        while($data = mysql_fetch_assoc($sel)){
        
            $total = $total + $data['rating_num'];
            $rows++;
        }
        
        $perc = ($total/$rows);
        
        return round($perc,2);
        //return round(($perc*2), 0)/2; // 3.5
    
    } else {
    
        return '0';
    
    }
    
    
}

function getVotes($id){

    $sel = mysql_query("SELECT rating_num FROM ratings WHERE rating_id = '$id'");
    $rows = mysql_num_rows($sel);
    if($rows == 0){
        $votes = '0 Votes';
    }
    else if($rows == 1){
        $votes = '1 Vote';
    } else {
        $votes = $rows.' Votes';
    }
    return $votes;
    
}

function pullRating($id,$show5 = false, $showPerc = false, $showVotes = false, $static = NULL){
    
    // Check if they have already voted...
    $sel = mysql_query("SELECT id FROM ratings WHERE IP = '".$_SERVER['REMOTE_ADDR']."' AND rating_id = '$id'");
    if(mysql_num_rows($sel) > 0 || $static == 'novote' || $_COOKIE['has_voted_'.$id]){
    
        $text = '';
        
        if($show5 || $showPerc || $showVotes){

            $text .= '<div class="rated_text">';
            
        }
            
            if($show5){
                $text .= 'Rated <span id="outOfFive_'.$id.'" class="out5Class">'.outOfFive($id).'</span>/5';
            } 
            if($showPerc){
                $text .= ' (<span id="percentage_'.$id.'" class="percentClass">'.getRating($id).'</span>)';
            }
            if($showVotes){
                $text .= ' (<span id="showvotes_'.$id.'" class="votesClass">'.getVotes($id).'</span>)';
            }
            
        if($show5 || $showPerc || $showVotes){    
            
            $text .= '</div>';
        
        }
        
        
        return $text.'
            <ul class="star-rating2" id="rater_'.$id.'">
                <li class="current-rating" style="width:'.getRating($id).';" id="ul_'.$id.'"></li>
                <li><a onclick="return false;" href="#" title="1 star out of 5" class="one-star" >1</a></li>
                <li><a onclick="return false;" href="#" title="2 stars out of 5" class="two-stars">2</a></li>
                <li><a onclick="return false;" href="#" title="3 stars out of 5" class="three-stars">3</a></li>
                <li><a onclick="return false;" href="#" title="4 stars out of 5" class="four-stars">4</a></li>
                <li><a onclick="return false;" href="#" title="5 stars out of 5" class="five-stars">5</a></li>
            </ul>
            <div id="loading_'.$id.'"></div>';

        
    } else {
        
        if($show5 || $showPerc || $showVotes){
            
            $text .= '<div class="rated_text">';
            
        }
            if($show5){
                $show5bool = 'true';
                $text .= 'Rated <span id="outOfFive_'.$id.'" class="out5Class">'.outOfFive($id).'</span>/5';
            } else {
                $show5bool = 'false';
            }
            if($showPerc){
                $showPercbool = 'true';
                $text .= ' (<span id="percentage_'.$id.'" class="percentClass">'.getRating($id).'</span>)';
            } else {
                $showPercbool = 'false';
            }
            if($showVotes){
                $showVotesbool = 'true';
                $text .= ' (<span id="showvotes_'.$id.'" class="votesClass">'.getVotes($id).'</span>)';
            } else {
                $showVotesbool = 'false';    
            }
            
        if($show5 || $showPerc || $showVotes){    
        
            $text .= '</div>';
            
        }
        
        return $text.'
            <ul class="star-rating" id="rater_'.$id.'">
                <li class="current-rating" style="width:'.getRating($id).';" id="ul_'.$id.'"></li>
                <li><a onclick="rate(\'1\',\''.$id.'\','.$show5bool.','.$showPercbool.','.$showVotesbool.'); return false;" href="includes/rating_process.php?id='.$id.'&rating=1" title="1 star out of 5" class="one-star" >1</a></li>
                <li><a onclick="rate(\'2\',\''.$id.'\','.$show5bool.','.$showPercbool.','.$showVotesbool.'); return false;" href="includes/rating_process.php?id='.$id.'&rating=2" title="2 stars out of 5" class="two-stars">2</a></li>
                <li><a onclick="rate(\'3\',\''.$id.'\','.$show5bool.','.$showPercbool.','.$showVotesbool.'); return false;" href="includes/rating_process.php?id='.$id.'&rating=3" title="3 stars out of 5" class="three-stars">3</a></li>
                <li><a onclick="rate(\'4\',\''.$id.'\','.$show5bool.','.$showPercbool.','.$showVotesbool.'); return false;" href="includes/rating_process.php?id='.$id.'&rating=4" title="4 stars out of 5" class="four-stars">4</a></li>
                <li><a onclick="rate(\'5\',\''.$id.'\','.$show5bool.','.$showPercbool.','.$showVotesbool.'); return false;" href="includes/rating_process.php?id='.$id.'&rating=5" title="5 stars out of 5" class="five-stars">5</a></li>
            </ul>
            <div id="loading_'.$id.'"></div>';
    
    }
}

// Added in version 1.5
function getTopRated($limit, $table, $idfield, $namefield){
    
    $result = '';
    
    $sql = "SELECT ratings.rating_id,".$table.".".$namefield." as thenamefield,ROUND(AVG(ratings.rating_num),2) as rating 
            FROM ratings,".$table." WHERE ".$table.".".$idfield." = ratings.rating_id GROUP BY rating_id 
            ORDER BY rating DESC LIMIT ".$limit."";
            
    $sel = mysql_query($sql);
    
    $result .= '<ul class="topRatedList">'."\n";
    
    while($data = mysql_fetch_assoc($sel)){
        $result .= '<li>'.$data['thenamefield'].' ('.$data['rating'].')</li>'."\n";
    }
    
    $result .= '</ul>'."\n";
    
    return $result;
    
}
?>

We will get there:lol:
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
still doesen't work :(
Edit:
Since it seems to be a hard problem I put 100 credits more as offer. So now you get 250 credits.
 
Last edited:

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/>
<meta name="description" content="Play free flash games at JAGF!"/>
<meta name="keywords" content="free, flash, games, free flash games, game, jagf, just, a, game, forum, just a game forum, jagf just a game forum, vigge swe, viggeswe, vigge_sWe, vigge_swe"/> 
<meta name="author" content="vigge_sWe"/> 
<link rel="stylesheet" type="text/css" href="default.css" media="screen"/>
<title>JAGF | FLASH GAMES | :þ </title>
<style type="text/css">
<!--
.style17 {
    font-family: trashco;
    font-size: 70px;
    color: #FFFF00;
}
.style18 {color: #FF0000}
.style21 {font-size: x-small}
-->
</style></head>

<body>
<?php include("includes/rating_functions.php"); ?>

<link href="css/rating_style.css" rel="stylesheet" type="text/css" media="all">

<script type="text/javascript" src="js/rating_update.js"></script> 

<div class="container">
    
    <div class="main">

        <div class="header">
        
            <div class="title">
                <h1><span class="style17">JAGF | FLASH GAMES </span></h1>
            </div>

        </div>
        
        <div class="content">
    
            <div class="item">

                <center><script type="text/javascript" src="http://x10hosting.com/adserve.js?viggeswe"></script>
        <script type="text/javascript"><!--
google_ad_client = "pub-0148207174309975";
//468x60, skapad 2007-11-17
google_ad_slot = "5631048737";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></center>
          </div>
    
            <div class="item">

                <h1>Welcome!</h1>
                <div class="descr">nov 17, 2007 by vigge_sWe </div>
                <p>Welcome to our flash section! We have all kinds of flash games. It is only to play them! When you're already here, please think about joining our forum <a href="http://jagf.pcriot.com" target="_blank">here!</a></p>
          </div>

<div class="item">

                <h1>Announcements</h1>

                <div class="descr">nov 18, 2007 by vigge_sWe </div>
          I am aware of that some games aren't showing right. This is because they were too big so it messed up the style. Theese games is still playable.          </div>
          
          <div class="item">

                <h1>Statistics</h1>
                <p>
                  <?php
include($_SERVER['DOCUMENT_ROOT']."/flash/counterh.php");
?>
                </p>
                <h1>Top ten</h1>
                <p>

<?php echo getTopRated(10,'ratings','rating_id','rating_title'); ?>
<?php var_dump($dbuser); ?>


&nbsp;      </p>
          </div>

        </div>

        <div class="sidenav">

            <h1>Main menu </h1>
            <ul>
                <li><a href="index.php">Back to home </a></li>
                <li><a href="http://jagf.net">Forum</a></li>
            </ul>

            <h1>Sponsored links </h1>
            <ul>
              <span class="style21">Want an link?              </span>
              <li class="style21">mail vigge.swe [AT] gmail [dot] com </li>
            </ul>

            <h1>Game list</h1>
            <p><?php
include($_SERVER['DOCUMENT_ROOT']."/flash/gamelist.php");
?></p>
            <h1>Search</h1>
            <form action="index.php">
            <div>
                <input type="text" name="search" class="styled" /> <input type="submit" value="" class="button" />
            </div>
            </form>

        </div>
    
        <div class="clearer"><span></span></div>

    </div>

    <div class="footer">&copy; <?php
    include($_SERVER['DOCUMENT_ROOT']."/flash/copyright.php");
    ?> <a href="http://jagf.pcriot.com">JAGF - Just A Game Forum</a>. Valid <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a> &amp; <a href="http://validator.w3.org/check?uri=referer">XHTML</a>. Template design by <a href="http://arcsin.se">Arcsin</a>
    </div>

</div>

</body>

</html>

The code I use is
PHP:
<?php echo getTopRated(10,'ratings','rating_id','rating_title'); ?>

PHP:
<?php include("includes/rating_functions.php"); ?>
at the top
 
Last edited:

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
OMG! I messed with the script and now it can connect! Just 1 problem left:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/viggeswe/public_html/flash/includes/rating_functions.php on line 208
 

supajason

Member
Messages
288
Reaction score
2
Points
18
you need to check the SQL it could be returning nothing, do you have some data?
 

galaxyAbstractor

Community Advocate
Community Support
Messages
5,508
Reaction score
35
Points
48
The ratings are working on the games and it shows the results for the game. It just don't want to show the top 10. It only comes with this error:

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/viggeswe/public_html/flash/includes/rating_functions.php on line 208
 
Top