Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2011
    Posts
    37
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question Whats wrong in this code..Please help fast

    Hello, all

    I have a error in my php script. But the problem is i can't find it.

    code is
    PHP Code:
    header("Cache-Control: no-cache");
    header("Pragma: nocache");

    require(
    '_config.php');

    //getting the values
    $iRateCount preg_replace("/[^0-9]/","",$_REQUEST['j']);
    $iRateId preg_replace("/[^0-9a-zA-Z]/","",$_REQUEST['q']);
    $iRaterId preg_replace("/[^0-9\.]/","",$_REQUEST['t']);
    $iRatedId preg_replace("/[^0-9]/","",$_REQUEST['c']);
    $ip $_SERVER['REMOTE_ADDR'];


    $vote_sent preg_replace("/[^0-9]/","",$_REQUEST['j']);
    $id_sent preg_replace("/[^0-9a-zA-Z]/","",$_REQUEST['q']);
    $ip_num preg_replace("/[^0-9\.]/","",$_REQUEST['t']);
    $units preg_replace("/[^0-9]/","",$_REQUEST['c']);

    $iUnits '5';
    if (
    $iRateCount $iUnits) die("Sorry, vote appears to be invalid.");

    switch (
    $iRateId) {
        case 
    'ease':
            
    easeQuery($iRateCount$iRateId$iRaterId$iRatedId$iUnits);
            break;
        case 
    'help':
            
    helpQuery();
            break;
        case 
    'clarity':
            
    clarityQuery();
            break;
        case 
    'interest':
            
    interestQuery();
            break;
        case 
    'textbook':
            
    textbookQuery();
            break;
        }

    function 
    easeQuery($ratecount$rateid$raterid$ratedid$units) {
        
    $query mysql_query("SELECT `ease_value`, `ease_count`, `ease_ids`, `user_id` FROM `pras_pr_ratings` WHERE `user_id` ='$ratedid' ");
        
    $aquery mysql_fetch_assoc($query);
        
    $checkid unserialize($aquery['ease_ids']);
        
    $count $aquery['ease_count'];
        
    $currentrate $aquery['ease_value'];
        
    $total $ratecount+$currentrate;
        
    $tense = ($count == 1) ? 'vote' :' votes';
        
        (
    $total==$added=$added$count 1);
        
        ((
    is_array($checkid)) ? array_push($checkid$raterid) : $checkid = array($raterid));
        
    $finalid serialize($checkid);
        
        
    $isquery mysql_query("SELECT `ease_ids` FROM `pras_pr_ratings` WHERE `ease_ids` LIKE '%".$raterid."%' AND `user_id` = $ratedid ");
        
    $israted mysql_num_rows($isquery);
        
            if (
    $ratecount >= '1' && $ratecount <= $units) {
                
    $update "UPDATE `pras_pr_ratings` SET ease_value='".$total."', ease_count='".$added."', used_ids='".$finalid."' WHERE user_id='$ratedid'";
                
    $result mysql_query($update);
        }


    Here the problem is in that update statement because when i echo the variables $total, $added, $finalid, $ratedid. They all give what they should but its not updating the database and database can be connected without any problems because i can read the values of $count, $currentrate etc etc..
    which come from database so it obvious that it can be connected.
    Am i doing something wrong please point it out.

    Thanks

  • #2
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    Whats wrong in this code..Please help fast
    When do you need a solution by?

    For starters, post the output from echoing the update sql statement.

  • #3
    New Coder
    Join Date
    Jul 2011
    Posts
    37
    Thanks
    3
    Thanked 0 Times in 0 Posts
    i didn't understand you properly. Do you mean echoing the update statement??
    but hows that possible.

    I just want to know what is wrong in the code. I think it should be something silly but i can find it.

  • #4
    New Coder
    Join Date
    Jul 2011
    Posts
    37
    Thanks
    3
    Thanked 0 Times in 0 Posts
    As i mentioned before something silly.. lol

    The problem was a typo in a column name. But thanks webdev and anyone who viewed this.

  • #5
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    Quote Originally Posted by Prashank View Post
    i didn't understand you properly. Do you mean echoing the update statement??
    but hows that possible.

    PHP Code:
    $query 'update myTable blah blah blah........';

    echo 
    $query; die(); 

  • #6
    Banned
    Join Date
    Apr 2011
    Posts
    656
    Thanks
    14
    Thanked 69 Times in 69 Posts
    glad you sorted it out


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •