+ Reply to Thread
Page 1 of 4 123 ... LastLast
Results 1 to 10 of 35

Thread: 150 credits to debug

  1. #1
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    150 credits to debug

    I need someone with php knowledge to debug this:

    PHP Code:
    <?
    include("includes/rating_config.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.
    */

    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) > || $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;
        
    }
    ?>
    this is the error it gives:
    Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/viggeswe/public_html/flash/includes/rating_functions.php on line 183

    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/viggeswe/public_html/flash/includes/rating_functions.php on line 183

    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 187
    Code between 183 and 189:

    PHP Code:
        $sel mysql_query($sql);
        
        
    $result .= '<ul class="topRatedList">'."\n";
        
        while(
    $data mysql_fetch_assoc($sel)){
            
    $result .= '<li>'.$data['thenamefield'].' ('.$data['rating'].')</li>'."\n";
        } 
    Last edited by galaxyAbstractor; 12-16-2007 at 07:33 AM.

  2. #2
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: 150 credits to debug

    Are you on stoli?

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


  3. #3
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: 150 credits to debug

    yes. And I have set the host right because the rating is working. But the script that should show the toprated shows the error. I got the script from here http://boedesign.com/posts/23.html there are some instruction I followed.

  4. #4
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: 150 credits to debug

    And where is the link on your site?

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


  5. #5
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: 150 credits to debug

    http://flash.jagf.net

    Now the error has changed:
    Warning: mysql_query() [function.mysql-query]: Access denied for user 'viggeswe'@'stoli.x10hosting.com' (using password: NO) in /home/viggeswe/public_html/flash/includes/rating_functions.php on line 183

    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/viggeswe/public_html/flash/includes/rating_functions.php on line 183

    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 187
    Last edited by galaxyAbstractor; 12-16-2007 at 08:07 AM.

  6. #6
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: 150 credits to debug

    Warning: mysql_query() [function.mysql-query]: Access denied for user 'viggeswe'@'stoli.x10hosting.com' (using password: NO) in /home/viggeswe/public_html/flash/includes/rating_functions.php on line 183
    Its not getting the dbuser/dbpass/dbname from your config file. Perhaps an absolute path may help.

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


  7. #7
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: 150 credits to debug

    And how do I do that? Can't I just in some way put in my database info in there so it don't need to load the config file? I got it! The idiot had typed in include("includes/rating_config.php"); instead of include("rating_config.php");.

    Still says the same thing. ANd btw, look at the x10 ad under the adsense! Should it be so? Mhhhh that was a new adsense function lol.
    Last edited by galaxyAbstractor; 12-16-2007 at 08:37 AM.

  8. #8
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: 150 credits to debug

    Echo out $dbuser and see what you get. Chances are its empty.

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


  9. #9
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: 150 credits to debug

    How do I do that???

    this is the database info I have putted in the config file <?
    $server = 'mysql.x10hosting.com';
    $dbuser = 'viggeswe_vigswe';
    $dbpass = '*my password*';
    $dbname = 'viggeswe_phpbb';

    $x = mysql_connect($server,$dbuser,$dbpass);
    mysql_select_db($dbname,$x);
    ?>
    Last edited by galaxyAbstractor; 12-16-2007 at 09:06 AM.

  10. #10
    Slothie's Avatar
    Slothie is offline Lord Of The Keys Slothie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Singapore
    Posts
    1,432

    Re: 150 credits to debug

    PHP Code:
    var_dump($dbuser); 
    in your index.php or wherever you call the rating script.
    Last edited by Slothie; 12-16-2007 at 09:24 AM.

    Easiest 70 points you'll make on x10

    Feel free to add my reputation by clicking on the if you found my post helpful to you :P


    If I am not responding to your PMs, that means I am ignoring you. Take a hint.



    09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0


+ Reply to Thread
Page 1 of 4 123 ... LastLast

Similar Threads

  1. Website Review
    By QuwenQ in forum The Marketplace
    Replies: 7
    Last Post: 03-24-2008, 11:05 PM
  2. Will draw for Credits
    By Emihaumut in forum The Marketplace
    Replies: 40
    Last Post: 01-09-2008, 07:12 PM
  3. Replies: 4
    Last Post: 11-27-2007, 06:49 PM
  4. Advertise me to easily double credits!
    By QuwenQ in forum The Marketplace
    Replies: 0
    Last Post: 11-01-2007, 04:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers