www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > PHP

    PHP Discussion and technical support for using and deploying PHP based websites.

    Reply
     
    Thread Tools Rate Thread Display Modes
      #1  
    Old 01-21-2005, 12:17 PM
    MeltedMonitor MeltedMonitor is offline
    Registered User
     
    Join Date: Apr 2003
    Posts: 34
    Cannot use object of type stdClass as array

    I recently moved my site onto a new server that runs PHP 5.0.3 and one of my scripts is now returning an error:

    Fatal error: Cannot use object of type stdClass as array in /home/scion/public_html/dealers/add_review.php on line 736

    Error Location:
    http://www.scionlife.com/dealers/add...&sub_cat_id=38

    Now I have been trying to research this error using Google, but it just seems to pull up pages that are having the same error, or forums that have mentioned this but their solution was to either switch back to the old version of PHP or to install new software. Those are not options here.

    I tried to research classes and then trawled through the file looking for bad code, but now I am just more confused:
    http://www.ocssolutions.com/manuals/...guage.oop.html

    So, can someone point me in a direction to look -- or offer to fix the code. I'll pay ya $50.

    Darren
    Reply With Quote
      #2  
    Old 01-21-2005, 12:50 PM
    NogDog's Avatar
    NogDog NogDog is offline
    High Energy Magic Dept.
     
    Join Date: Aug 2004
    Location: Ankh-Morpork
    Posts: 14,867
    Stab in the dark: set zend.ze1_compatibility_mode ON. You could try putting a init_set("zend.ze1_compatibility_mode","1"); at the start of your script and see if that helps.
    __________________
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    Kindle Minds (blog about Amazon Kindle)
    Reply With Quote
      #3  
    Old 01-21-2005, 12:58 PM
    MeltedMonitor MeltedMonitor is offline
    Registered User
     
    Join Date: Apr 2003
    Posts: 34
    That looked SO good, but didn't work. By the way, I had to lookup the function because it didn't work at first. The function is actually ini_set() -- but it was a great idea.

    Hmmm.... hopefully there is someone that knows!
    Reply With Quote
      #4  
    Old 01-21-2005, 01:26 PM
    NogDog's Avatar
    NogDog NogDog is offline
    High Energy Magic Dept.
     
    Join Date: Aug 2004
    Location: Ankh-Morpork
    Posts: 14,867
    Can you upload the PHP file here as a textfile upload, or cut-and-paste the offending line 736 along with maybe 10-20 lines before it?
    __________________
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    Kindle Minds (blog about Amazon Kindle)
    Reply With Quote
      #5  
    Old 01-21-2005, 01:30 PM
    MeltedMonitor MeltedMonitor is offline
    Registered User
     
    Join Date: Apr 2003
    Posts: 34
    Sure. I don't think that the offending line is actually the culprit. The offending line is the first line of this batch:

    PHP Code:
    // error found - display the error message here
    if ( $result[error_msg] != "")
        {
        echo
    "<br>" . $result[error_msg] . "<br>\n";
        }
    Reply With Quote
      #6  
    Old 01-21-2005, 01:32 PM
    MeltedMonitor MeltedMonitor is offline
    Registered User
     
    Join Date: Apr 2003
    Posts: 34
    Part 1 of file (maximum posts 10,000 chars)

    PHP Code:
    <?php

    require ( "config.php" );
    require (
    "common.php" );
    require (
    "includes/inc_reviews.php" );
    require (
    "includes/validate_form.php" );
    require (
    "includes/interface.php" );
    require (
    "includes/functions.php" );
    require (
    "global_config.php");
    require (
    "language.php");

    ////////////////////////////////// Start of functions /////////////////////////

    function check_review ( &$review_title, &$review_text, &$reviewer_name, $reviewer_email, $agree )
        {
        
        global
    $error_message, $db, $item, $item_type, $item_id, $type;
        global
    $CONFIG_VAR, $_SERVER, $_SESSION, $lang;

        
    $item = ucwords ( $item );

        
    // Define censored word matches
        
    if ( empty($orig_word) && empty($replacement_word) )
            {
            
    $orig_word = array();
            
    $replacement_word = array();

            
    obtain_word_list( $orig_word, $replacement_word );
            }

        
    // Check the review title field - can be left blank, defaults to item type as text
        
    if ( $review_title != "" )
            {
            
    $result = check_field ( $review_title, $lang['add_review_error_1'], 1, 60 );
            if (
    $result[error] == true )
                {
                return array(
    'error' => true, 'error_msg' => $result[error_msg] );
                }
            }
        else
            {
            
    $review_title = ucwords ( $item );
            }
        
    $review_title = trim ( $review_title );

        
        
    // Check the review text field
        
    $result = check_field ( $review_text, $lang['add_review_error_2'], 1, 3000 );
        if (
    $result[error] == true )
            {
            return array(
    'error' => true, 'error_msg' => $result[error_msg] );
            }

        
    $review_text = trim ( $review_text );
      
        
    // check the name and email fields only if email authentication is required
        
    switch ( $CONFIG_VAR['authentication'] )
            {
            case
    "phpbb":
                break;

            case
    "none":
                break;
            
            case
    "email":
                if (
    $type != "edit" )
                    {
                    
    // Don't allow " in reviewer name.
                    
    if ( strstr( $reviewer_name, '"' ) )
                        {
                        return array(
    'error' => true, 'error_msg' => create_error_message ( $lang['add_review_error_3'] ));
                        }

                    
    // Check the reviewer name field       
                    
    $result = check_field ( $reviewer_name, $lang['add_review_error_4'], 1, 50 );
                    if (
    $result[error] == true )
                        {
                        return array(
    'error' => true, 'error_msg' => $result[error_msg] );
                        }
                    
    $reviewer_name = trim ( strip_tags ( $reviewer_name ) );
                    
                    
    // Check the email field
                    
    $email = strtolower ( $reviewer_email );
                    
    $result = validate_email ( $email );
                    if (
    $result == false )
                        {
                        return array(
    'error' => true, 'error_msg' => create_error_message ( $lang['add_review_error_5'] ) );
                        }
                
                    
    // Check that this user is not banned
                    
    $result = check_banned ( $email );
                    if (
    $result[error] == true )
                        {
                        return array(
    'error' => true, 'error_msg' => $result[error_msg] );
                        }
                    }
                break;
            }

        if (
    $type == "add" )
            {
            
    // do not check for duplicate entries if the administrator is logged in or multiple reviews override has been set in the admin CP
            
            
    $allow_multiple_reviews = $CONFIG_VAR['multiple_reviews'];
            
            if (
    $_SESSION['logged_in'] == true )
                {
                
    $allow_multiple_reviews = "yes";
                }

            if (
    $allow_multiple_reviews != "yes" )
                {
                if (
    $CONFIG_VAR['authentication'] != "none" )
                    {
                    
    // ensure that the user has not posted a review for this supplier already, testing email address
                    
    $query = "SELECT review_id FROM dealers_reviews WHERE item_id=$item_id AND reviewer_email='$reviewer_email'";
                    
    $result = $db->get_results( $query );
                    if (
    $db->num_rows > 0 )
                        {
                        return array(
    'error' => true, 'error_msg' => create_error_message ( $lang['add_review_error_6'] . $item ) );
                        }
                    }

                
    // ensure that the user has not posted a review for this supplier already, testing IP address
                
    $ip_address = $_SERVER['REMOTE_ADDR'];
                
    $query = "SELECT review_id FROM dealers_reviews WHERE item_id=$item_id AND ip_address='$ip_address'";
                
    $result = $db->get_var( $query );
                if (
    $db->num_rows > 0 )
                    {
                    return array(
    'error' => true, 'error_msg' => create_error_message ( $lang['add_review_error_6'] . $item ) );
                    }
                }
            }
        
        
    // bleep out any swear words
        
    if ( count ( $orig_word ) )
            {
            
    $review_title = preg_replace($orig_word, $replacement_word, $review_title );
            
    $review_text = preg_replace($orig_word, $replacement_word, $review_text );        
            }

        
    // check that the terms have been accepted, if the admin has chosen the terms to be displayed
        
    if ( $CONFIG_VAR['register_show_terms'] == "yes" )
            {
            switch (
    $CONFIG_VAR['authentication'] )
                {
                case
    "phpbb":
                    break;
                default:
                    if (
    $agree != "yes" )
                        {
                        
    $error_message = create_error_message ( $lang['add_review_error_7'] );
                        return array(
    'error' => true, 'error_msg' => $error_message );
                        }        
                    break;
                }
            }

        return array(
    'error' => false, 'error_msg' => "" );
        }


    function
    review_rating_algorithm ( $score_1, $score_2, $score_3, $score_4, $score_5, $score_6, $score_7, $score_8 )
        {
        
    // find the average of the criteria scores
        
    $average = 0;
        
    $number = 0;
        
    $total = 0;
        for (
    $counter=1; $counter<=8; $counter++ )
            {
            
    $var= "score_" . $counter;
            if (
    is_numeric ( $$var ) )
                {
                
    $number++;
                
    $total = $total + $$var;
                }
            }

        if (
    $total != 0 )
            {
            
    $average = $total/$number ;
            
    $average = ( integer ) $average;
            }
            
        return
    $average;
        }


    function
    edit_access_error()
        {
        global
    $CONFIG_VAR, $page, $lang;

        
    include_template ( $CONFIG_VAR['page_header_template'] );

        
    // This creates the start of the main body table
        
    echo "<!-- Start of main body table -->\n\n";

        echo
    "<table width=\"" . $CONFIG_VAR['body_width_value'] . "\" align=\"center\" cellspacing=\"0\" border=\"0\" cellpadding=\"0\">\n";
        echo
    "<tr>\n";


        
    // This creates the lefthand menu column
        
    include_template ( $CONFIG_VAR['left_column_template'] );

        
    // This creates the middle table
        
    echo "<!-- Start of middle column -->\n\n";
        echo
    "<td valign=\"top\">\n";
        
    breadcrumbs( "error" );

        
    print_message ( $lang['add_review_message_1'], $lang['add_review_message_2'] );
        die;
        }


    function
    print_hidden_field ( $name, $value )
        {
        echo
    "<input type=\"hidden\" name=\"$name\" value=\"$value\">\n";
        }


    function
    clean_key($key) {

        if (
    $key == "")
        {
            return
    "";
        }
        
    $key = preg_replace( "/\.\./"           , ""  , $key );
        
    $key = preg_replace( "/\_\_(.+?)\_\_/"  , ""  , $key );
        
    $key = preg_replace( "/^([\w\.\-\_]+)$/", "$1", $key );
        return
    $key;
        }


    function
    text_display( $bgcolour, $column1_width, $column2_width, $text, $value )
        {
        echo
    "<tr bgcolor=\"$bgcolour\">\n";
        echo
    "<td width=\"$column1_width\" class=\"tbody\" bgcolor=\"#EEEEEE\">" . $text . "</td>\n";
        echo
    "<td width=\"$column2_width\" class=\"tbody\">$value</td>\n";
        echo
    "</tr>\n";
        }

    ////////////////////////////////// End of functions /////////////////////////
    session_start();
    header("Cache-control: private"); // IE 6 Fix.

    $mode        = $_GET['mode'];
    $cat_id        = $_GET['cat_id'];
    $sub_cat_id = $_GET['sub_cat_id'];
    $item_id    = $_GET['item_id'];
    $review_id    = $_GET['review_id'];
    $type        = $_GET['type'];
    $offset        = $_GET['offset'];

    $page = "add_review";

    // Check for authentication, but not if the adminsitrator is logged in
    if ( $_SESSION['logged_in'] != "true" )
        {
        
    check_authentication ( $CONFIG_VAR['authentication'] );
        }

    require (
    "includes/mysql.php" );
    global
    $db;

    if (
    $mode == "" )
        {
        
    $type = "add";
        }

    if (
    $mode == "edit" )
        {
        
    $type = "edit";
        
    $page = "edit_review";
        switch (
    $CONFIG_VAR['authentication'] )
            {
            case
    "reviewcast":
                
    $username = $_COOKIE[ 'username'];
                break;

            case
    "invision":
                
    $result = invision_member_details();
                if (
    $result['error'] == false ) // no errors found
                    
    {
                    
    $username = $result['name'];
                    }
                break;

            case
    "phpbb":
                
    $username = $_SESSION['phpbb_username'];
                break;
            }
    Reply With Quote
      #7  
    Old 01-21-2005, 01:33 PM
    MeltedMonitor MeltedMonitor is offline
    Registered User
     
    Join Date: Apr 2003
    Posts: 34
    Part 2 of file (maximum posts 10,000 chars)

    PHP Code:
        if ( $_SESSION['logged_in'] == "true" )
            {
            
    $query = "SELECT * FROM dealers_reviews WHERE review_id = '$review_id'";
            }
        else
            {
             if (
    $CONFIG_VAR['authentication'] == "phpbb" || $CONFIG_VAR['authentication'] == "email"  )
                {
                
    $query = "SELECT * FROM dealers_reviews WHERE review_id = '$review_id' AND reviewer_name='$username'";    
                if (
    $CONFIG_VAR['authentication'] == "email" )
                    {
                    
    $email = $_POST['email'];
                    
    $query = "SELECT * FROM dealers_reviews WHERE review_id = '$review_id' AND reviewer_email='$email'";
                    }
                }
            else
                {
                
    edit_access_error();
                }
            }
                
        
    $result=$db->get_row ( $query );
        if (
    $db->num_rows == 0 )
            {
            
    edit_access_error();
            }
        else
            {
            
    $review_title   = $result->review_title;
            
    $review_text    = $result->review_text;
            
    $score_1        = $result->score_1;
            
    $score_2        = $result->score_2;
            
    $score_3        = $result->score_3;
            
    $score_4        = $result->score_4;
            
    $score_5        = $result->score_5;
            
    $score_6        = $result->score_6;
            
    $score_7        = $result->score_7;
            
    $score_8        = $result->score_8;
            
    $recommend      = $result->recommend;
            
    $display_name   = $result->display_name;
            if (
    $CONFIG_VAR['authentication'] == "email" )
                {
                
    $reviewer_name  = $result->reviewer_name;
                
    $reviewer_email = $result ->reviewer_email;
                }
            }
        }

    include
    "../guts/_hdr_dealers.php";

    echo
    "
    <table width=800 border=0 cellspacing=0 cellpadding=0 bgcolor=#FFFFFF height=400>
      <tr>
        <td width=10>&nbsp</td>
        <td valign=top>
    "
    ;

    // Find the category and sub category names
    $query = "SELECT dealers_categories.category,
                    dealers_sub_categories.sub_category
                    FROM dealers_categories
                    INNER JOIN dealers_sub_categories ON dealers_categories.cat_id = dealers_sub_categories.cat_id
                    WHERE dealers_sub_categories.cat_id='$cat_id' AND dealers_sub_categories.sub_cat_id='$sub_cat_id'"
    ;
    $result = $db->get_row ( $query );
    $category = $result->category;
    $sub_category = $result->sub_category;

    if (
    $db->num_rows == 0 )
        {
        
    // This creates the breadcrumb trail
        
    breadcrumbs( "error" );

        
    print_message ( $lang['add_review_message_3'], $lang['add_review_message_'] );
        die;
        }

    // Find the item details
    $query = "SELECT item FROM dealers_items WHERE item_id='$item_id'";
    $item = $db->get_var ( $query );
    if (
    $db->num_rows == 0 )
        {
        
    breadcrumbs( "error" );
        
    print_message ( $lang['add_review_message_5'], $lang['add_review_message_6'] );
        die;
        }

    if (
    $mode == "delete" )
        {
        
    $page = "delete_review";
        }

    // This creates the breadcrumb trail
    breadcrumbs( $page );

    // find the scoring names for this category    
    $array_score_names = find_score_names ( $cat_id );
    $score_1_name = $array_score_names[ 'score_1_name' ];
    $score_2_name = $array_score_names[ 'score_2_name' ];
    $score_3_name = $array_score_names[ 'score_3_name' ];
    $score_4_name = $array_score_names[ 'score_4_name' ];    
    $score_5_name = $array_score_names[ 'score_5_name' ];
    $score_6_name = $array_score_names[ 'score_6_name' ];
    $score_7_name = $array_score_names[ 'score_7_name' ];
    $score_8_name = $array_score_names[ 'score_8_name' ];    

    //Change the authentication variable to none if the administrator is logged in   
    if ( $_SESSION['logged_in'] == "true" )
        {
        
    $CONFIG_VAR['authentication'] = "none";
        }

    switch (
    $mode )
        {
        case
    "delete":
            
    // check that this review exists
            
    $query = "SELECT review_id FROM dealers_reviews WHERE review_id='$review_id'";
            
    $result = $db->get_var ( $query );
            if (
    $db->num_rows == 0 )
                {
                
    print_message ( $lang['add_review_message_5'], $lang['add_review_message_7'] );
                die;
                }

            
    // delete the review from the reviews table
            
    $query = "DELETE FROM dealers_reviews WHERE review_id='$review_id'";
            
    $db->query ( $query);

            
    print_message ( $lang['add_review_message_8'], $lang['add_review_message_9'] );
            die;
            break;

        case
    "confirm":
            
    $review_title       = $_POST['review_title'];
            
    $review_text        = $_POST['review_text'];
            
    $score_1            = $_POST['score_1'];
            
    $score_2            = $_POST['score_2'];
            
    $score_3            = $_POST['score_3'];
            
    $score_4            = $_POST['score_4'];
            
    $score_5            = $_POST['score_5'];
            
    $score_6            = $_POST['score_6'];
            
    $score_7            = $_POST['score_7'];
            
    $score_8            = $_POST['score_8'];
            
    $recommend          = $_POST['recommend'];
            
    $display_name       = $_POST['display_name'];
            
    $reviewer_name      = $_POST['reviewer_name'];
            
    $reviewer_email     = $_POST['reviewer_email'];
            
    $agree              = $_POST['agree'];

            switch (
    $CONFIG_VAR['authentication'] )
                {
                case
    "phpbb":
                    
    $active         = "yes";
                    break;

                case
    "none":
                    
    $active         = "yes";
                    break;
                
                case
    "email":
                    
    $active         = "no";
                    break;
                }

            
    $result = check_review ( $review_title, $review_text, $reviewer_name, $reviewer_email, $agree );
            if (
    $result[error] == false )
                {
                
    $date_added = date( "j F Y" );
                
                
    $review_score = review_rating_algorithm ( $score_1, $score_2, $score_3, $score_4, $score_5, $score_6, $score_7, $score_8 );

                
    print_review( "preview", $cat_id, $item_id, $review_title, $review_text, $score_1, $score_2, $score_3, $score_4, $score_5, $score_6, $score_7, $score_8, $review_score, $recommend, $reviewer_name, $date_added, $display_name, 0, $reviewer_email );

                
    // echo the confirmation form
                
    echo "<br>\n";
                echo
    "<form name=\"form1\" action=\"add_review.php?mode=post&item_id=" . $item_id . "&cat_id=" . $cat_id . "&sub_cat_id=" . $sub_cat_id . "&type=" . $type . "\" method=\"post\">\n";
                echo
    "<table width=\"90%\" border=\"0\" align=\"center\" bgcolor=\"#EEEEEE\">\n";
                echo
    "<tr>\n";
                echo
    "<td colspan=\"3\" class=\"dealersreviewtext\" align=\"center\">" . $lang['add_review_message_10'] . "</td>\n";
                echo
    "</tr>\n";
                echo
    "<tr>\n";
                echo
    "<td colspan=\"3\"><img src=\"images/spacer.gif\" width=\"1\" height=\"5\" alt=\"\"></td>\n";
                echo
    "</tr>\n";
                
                if (
    $CONFIG_VAR['authentication'] == "email" && $type != "edit" )
                    {
                    echo
    "<tr>\n";
                    echo
    "<td colspan=\"3\" align=\"center\" class=\"dealersreviewtext\"><b>" . $lang['add_review_message_11'] . "</td>\n";
                    echo
    "</tr>\n";
                    }

                echo
    "<tr>\n";
                echo
    "<td colspan=\"3\"><img src=\"images/spacer.gif\" width=\"1\" height=\"5\" alt=\"\"></td>\n";
                echo
    "</tr>\n";
                echo
    "<tr>\n";
                echo
    "<td>\n";
                echo
    "<div align=\"right\">\n";
                echo
    "<input type=\"button\" name=\"Submit2\" value=\"" . $lang['add_review_form_button_1'] . "\" onclick=\"javascript:history.back()\">\n";
                echo
    "</div>\n";
                echo
    "</td>\n";
                echo
    "<td>&nbsp;</td>\n";
                echo
    "<td>\n";
                echo
    "<div align=\"left\">\n";
                echo
    "<input type=\"submit\" name=\"Submit\" value=\"" . $lang['add_review_form_button_2'] . "\">\n";
                echo
    "</div>\n";
                echo
    "</td>\n";
                echo
    "<tr>\n";
                echo
    "<td colspan=\"3\">\n";
                                                   
                
    print_hidden_field ( "review_title",    strip_slashes ( $review_title ) );
                
    print_hidden_field ( "review_text",     strip_slashes ( $review_text ) );
                
    print_hidden_field ( "score_1",         $score_1 );
                
    print_hidden_field ( "score_2",         $score_2 );
                
    print_hidden_field ( "score_3",         $score_3 );
                
    print_hidden_field ( "score_4",         $score_4 );
                
    print_hidden_field ( "score_5",         $score_5 );
                
    print_hidden_field ( "score_6",         $score_6 );
                
    print_hidden_field ( "score_7",         $score_7 );
                
    print_hidden_field ( "score_8",         $score_8 );
                
    print_hidden_field ( "review_score",    $review_score );
                
    print_hidden_field ( "recommend",       $recommend );
                
    print_hidden_field ( "reviewer_name",   $reviewer_name );
                
    print_hidden_field ( "reviewer_email",  $reviewer_email );
                
    print_hidden_field ( "display_name",    $display_name );
                
    print_hidden_field ( "active",          $active );
                
    print_hidden_field ( "type",            $type );
                
    print_hidden_field ( "review_id",       $review_id );
                
                echo
    "</td>\n";
                echo
    "</tr>\n";
                echo
    "<tr><td colspan=\"3\">&nbsp;<td><tr>\n";
                echo
    "</table>\n";
                echo
    "</form>\n";


    //This creates the main menu along the bottom of the main column
    //bottom_menu( "no" );

    echo "
          <br>
        </td>
        <td width=16 background=\"../guts/rbuffer_yw.gif\">&nbsp;</td>
      </tr>
    </table>
    <table width=800 border=0 cellspacing=0 cellpadding=0 background=\"../guts/bbuffer_yw.gif\" height=3>
      <tr>
        <td></td>
      </tr>
    </table>
    "
    ;
    Reply With Quote
      #8  
    Old 01-21-2005, 01:37 PM
    MeltedMonitor MeltedMonitor is offline
    Registered User
     
    Join Date: Apr 2003
    Posts: 34
    Part 3 of file (maximum posts 10,000 chars)

    PHP Code:
    include "../guts/_ftr.php";

                die;
                }
            else
                {
                
    $review_title   = strip_slashes ( $review_title );
                
    $review_text    = strip_slashes ( $review_text );        
                }
            break;

        case
    "post":
            
    $review_title       = $_POST['review_title'];
            
    $review_text        = $_POST['review_text'];
            
    $score_1            = $_POST['score_1'];
            
    $score_2            = $_POST['score_2'];
            
    $score_3            = $_POST['score_3'];
            
    $score_4            = $_POST['score_4'];
            
    $score_5            = $_POST['score_5'];
            
    $score_6            = $_POST['score_6'];
            
    $score_7            = $_POST['score_7'];
            
    $score_8            = $_POST['score_8'];
            
    $review_score       = $_POST['review_score'];
            
    $recommend          = $_POST['recommend'];
            
    $reviewer_name      = $_POST['reviewer_name'];
            
    $reviewer_email     = $_POST['reviewer_email'];
            
    $display_name       = $_POST['display_name'];
            
    $active             = $_POST['active'];
            
    $type               = $_POST['type'];
            
    $review_id          = $_POST['review_id'];
            
            
    $ip_address         = $_SERVER['REMOTE_ADDR'];

            
    $review_title       = add_slashes ( $review_title ) ;
            
    $review_text        = add_slashes ( $review_text ) ;       
            
    $reviewer_email     = strtolower ( $reviewer_email );
         
            
    $review_score = review_rating_algorithm ( $score_1, $score_2, $score_3, $score_4, $score_5, $score_6, $score_7, $score_8 );
        
            if (
    $type == "edit" )
                {
                
    $query = "UPDATE dealers_reviews SET
                    review_title        = '$review_title',
                    review_text         = '$review_text',
                    score_1             = '$score_1',
                    score_2             = '$score_2',
                    score_3             = '$score_3',
                    score_4             = '$score_4',
                    score_5             = '$score_5',
                    score_6             = '$score_6',
                    score_7             = '$score_7',
                    score_8             = '$score_8',
                    review_score        = '$review_score',
                    recommend           = '$recommend',
                    ip_address          = '$ip_address',
                    display_name        = '$display_name'
                    WHERE review_id     ='$review_id'"
    ;

                    
    $db->query ( $query );
                    
    print_message ( $lang['add_review_message_12'], $lang['add_review_message_13'] );
                    die;
                }

            
    // Check again that they are not posting a review twice, but not if logged in as administrator
            
    if ( $_SESSION['logged_in'] != "true" )
                {
                
    $query = "SELECT review_id
                FROM dealers_reviews
                WHERE item_id='$item_id'
                AND reviewer_email='$reviewer_email'"
    ;
                
                if  (
    $CONFIG_VAR['authentication'] == "none" )
                    {
                    
    $query = "SELECT review_id
                    FROM dealers_reviews
                    WHERE item_id='$item_id'
                    AND ip_address='$ip_address'"
    ;
                    }

                    
    $result = $db->get_results ( $query );
                    if (
    $db->num_rows > 0 )
                        {
                        
    print_message ( $lang['add_review_message_5'], $lang['add_review_message_14'] );
                        die;
                        }
                }
            
            
    // post the review into the database
            
    $date_added = date( "j F Y" );
            
    $timestamp = time();

            
    $query = "INSERT INTO dealers_reviews ( item_id,
                        review_title,
                        review_text,
                        score_1,
                        score_2,
                        score_3,
                        score_4,
                        score_5,
                        score_6,
                        score_7,
                        score_8,
                        review_score,
                        recommend,
                        reviewer_name,
                        reviewer_email,
                        ip_address,
                        display_name,
                        date_added,
                        rec_timestamp
                        )
                            
                        VALUES ( '$item_id',
                            '$review_title',
                            '$review_text',                        
                            '$score_1',
                            '$score_2',
                            '$score_3',
                            '$score_4',
                            '$score_5',
                            '$score_6',
                            '$score_7',
                            '$score_8',
                            '$review_score',
                            '$recommend',
                            '$reviewer_name',
                            '$reviewer_email',
                            '$ip_address',
                            '$display_name',
                            '$date_added',
                            '$timestamp' )"
    ;

             
    $db->query( $query );
             
    $review_id = $db->insert_id;

             
    // create the hash for review_id
             
    $hash_review_id = md5 ( $review_id );
            
            
    //set the active field to "no" if all reviews are to be approved

            
    if ( $CONFIG_VAR['approve_reviews'] == "yes" )
                {
                
    $active = "no";
                
    $CONFIG_VAR['authentication'] = "approve";
                }

            
    // update the review record with this hash
            
    $query = "UPDATE dealers_reviews SET hash_review_id=" . "'" . $hash_review_id . "', active='$active' WHERE review_id=" . "'" . $review_id . "'";
            
    $db->query( $query );
            
            if (
    $CONFIG_VAR['authentication'] == "invision" || $CONFIG_VAR['authentication'] == "phpbb" )
                {
                
    $CONFIG_VAR['authentication'] = "reviewcast";
                }
    Reply With Quote
      #9  
    Old 01-21-2005, 01:39 PM
    MeltedMonitor MeltedMonitor is offline
    Registered User
     
    Join Date: Apr 2003
    Posts: 34
    Part 4 of file (maximum posts 10,000 chars)

    PHP Code:

            
    switch ( $CONFIG_VAR['authentication'] )
                {
                case
    "approve":
                    
    $message_1 = $lang['add_review_message_15'];
                    
    $message_2 = $lang['add_review_message_17'];
                    break;

                case
    "none":
                    
    $message_1 = $lang['add_review_message_15'];
                    
    $message_2 = $lang['add_review_message_16'];
                    break;

                case
    "email":
                    
    $message_1 = $lang['add_review_message_15'];
                    
    $message_2 = $lang['add_review_message_18'];

                    
    // send email to the reviewer for confirmation

                    
    $mail_subject = $lang['add_review_mail_subject'];

                    
    $mail_body .= $lang['add_review_message_19'] . "\n\n";
                    
    $mail_body .= $CONFIG_VAR['reviewcast_url'] . "/confirm_review.php?id=".$hash_review_id . "\n\n";
                    
    $mail_body .= $lang['add_review_message_20'] . "\n\n";
                    
    $mail_body .= $lang['add_review_message_21'] . "\n\n";
                    
    $mail_body .= $lang['add_review_mail_regards'];
                    
    $mail_header = "From: " . $CONFIG_VAR['webmaster_email'] . "\r\n";

                    
    mail ( $reviewer_email, $mail_subject, $mail_body , $mail_header );
                    break;
                }
            
    // display the thank you page
            
    print_message ( $message_1, $message_2 );
            die;
            break;
        }


    // error found - display the error message here
    if ( $result[error_msg] != "")
        {
        echo
    "<br>" . $result[error_msg] . "<br>\n";
        }

    $bgcolour = "#" . $CONFIG_VAR['list_cell_colour'];
    $column1_width = "30%";
    $column2_width = "70%";
    $field_width = "35";
    $button_text = $lang['add_review_form_button'];

    // This creates the included review guideline, if any
    include ( "templates/dealers_review_guidelines.html" );

    echo
    "<form method=\"post\" action=\"add_review.php?mode=confirm&item_id=" . $item_id . "&cat_id=" . $cat_id . "&sub_cat_id=" . $sub_cat_id . "&type=" . $type . "&review_id=" . $review_id . "\">\n";
    echo
    "<table width=\"90%\" height=\"70\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" bgcolor=\"#" . $CONFIG_VAR['list_line_colour'] . "\" align=\"center\">\n";

    form_header_line ( "<b>" . $lang['add_review_form_header_1'] . ucwords ( $item ) . "</b>" );

    $tab_count = 1;

    // Who is writing this review?  Either we know or we need to know!

    $result = phpbb_member_details();
    if (
    $result['error'] == false ) {
        
    $phpbb_name = $result['name'];
        
    $phpbb_id = $result['phpbb_id'];
        
    $phpbb_posts = $result['phpbb_posts'];
        
    $reviewer_name  =  "$phpbb_name ($phpbb_posts)";
        
    $reviewer_email = $phpbb_id;
        
    $active         = "yes";
    }

    if (
    $reviewer_name) {
        echo
    "
            <tr>
              <td width=30% class=tbody valign=top bgcolor=#EEEEEE>
                <b>You are logged in as: </b>
              </td>
              <td width=70% class=tbody bgcolor=#FFFFFF>
                <a href=\"http://www.scionlife.com/forums/profile.php?mode=viewprofile&u=$reviewer_email\" target=_blank>$reviewer_name</a>
                <input type=hidden name=reviewer_name value=\"$reviewer_name\">
                <input type=hidden name=reviewer_email value=\"$reviewer_email\">
              </td>
             "
    ;
    }
    else {
                
    $tab_count ++;
                
    // This creates the reviewer_name field
                
    $text = "<b>" . $lang['add_review_form_name'] . "</b>";
                
    text_input( $bgcolour, "text", $column1_width, $column2_width, $text, "reviewer_name", $reviewer_name, $field_width, "n", $tab_count );
                
                
    $tab_count ++;
                
    // This creates the reviewer_email field
                
    $email_text = $lang['add_review_form_email_text'];
                
    $text = "<b>" . $lang['add_review_form_email'] . "</b><br><span class=\"tbodysmall\">" . $email_text . "</span>";
                
    text_input( $bgcolour, "text", $column1_width, $column2_width, $text, "reviewer_email", $reviewer_email, $field_width, "e", $tab_count );
    }

    // This creates the review title field
    echo "<input type=hidden name=review_title value=''>";

    $tab_count++;
    // This creates the review text box
    $text = $lang['add_review_form_review_text'];
    echo
    "<tr bgcolor=\"$bgcolour\">\n";
    echo
    "<td width=\"$column1_width\" class=\"tbody\" valign=\"top\" bgcolor=\"#" . $CONFIG_VAR['list_background_colour'] . "\">$text</td>\n";
    echo
    "<td width=\"$column2_width\" class=\"tbody\">\n";
    echo
    "<textarea name=\"review_text\" cols=\"35\" rows=\"10\" wrap=\"soft\" class=\"formelement\" accesskey=\"t\" tabindex=\"" . $tab_count . "\">" . $review_text . "</textarea>\n";
    echo
    "</td>\n";
    echo
    "</tr>\n";

    form_header_line ( "<b>" . $lang['add_review_form_header_2'] . "</b> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <font color=red><b>Ratings that contain all \"10's\" will be deleted unless they are qualified by your review text.  Rate accurately!  </b></font>" );

    // find the scoring names for this category    
    $array_score_names = find_score_names ( $cat_id );    

    if (
    $array_score_names[ 'score_1_name' ] != "" )
        {
        
    $tab_count++;
        
    create_scores_list ( "score_1", $array_score_names[ 'score_1_name' ], $score_1, $tab_count  );
        }

    if (
    $array_score_names[ 'score_2_name' ] != "" )
        {
        
    $tab_count++;
        
    create_scores_list ( "score_2", $array_score_names[ 'score_2_name' ], $score_2, $tab_count );
        }

    if (
    $array_score_names[ 'score_3_name' ] != "" )
        {
        
    $tab_count++;
        
    create_scores_list ( "score_3", $array_score_names[ 'score_3_name' ], $score_3, $tab_count );
        }

    if (
    $array_score_names[ 'score_4_name' ] != "" )
        {
        
    $tab_count++;
        
    create_scores_list ( "score_4", $array_score_names[ 'score_4_name' ], $score_4, $tab_count );
        }

    if (
    $array_score_names[ 'score_5_name' ] != "" )
        {
        
    $tab_count++;
        
    create_scores_list ( "score_5", $array_score_names[ 'score_5_name' ], $score_5, $tab_count  );
        }

    if (
    $array_score_names[ 'score_6_name' ] != "" )
        {
        
    $tab_count++;
        
    create_scores_list ( "score_6", $array_score_names[ 'score_6_name' ], $score_6, $tab_count );
        }

    if (
    $array_score_names[ 'score_7_name' ] != "" )
        {
        
    $tab_count++;
        
    create_scores_list ( "score_7", $array_score_names[ 'score_7_name' ], $score_7, $tab_count );
        }

    if (
    $array_score_names[ 'score_8_name' ] != "" )
        {
        
    $tab_count++;
        
    create_scores_list ( "score_8", $array_score_names[ 'score_8_name' ], $score_8, $tab_count );
        }

    $tab_count++;
    // This creates the recommend drop down list
    form_radio_boxes ( "<b>" . $lang['add_review_form_recommend'] .  "\"" . ucwords ( $item ) . "\" :</b>", "recommend", $recommend, $tab_count );
    $tab_count++; // increment this as checkboxes take two tab index values (one for yes, one for no)

    // We will NEVER show the terms in this customized version of this script
    $CONFIG_VAR['register_show_terms'] = "no";

    $tab_count++;
    form_submit_button ( $button_text, $tab_count );

    echo
    "</table>\n";
    echo
    "</form>\n";

    //This creates the main menu along the bottom of the main column
    //bottom_menu( "no" );

    echo "
          <br>
        </td>
        <td width=16 background=\"../guts/rbuffer_yw.gif\">&nbsp;</td>
      </tr>
    </table>
    <table width=800 border=0 cellspacing=0 cellpadding=0 background=\"../guts/bbuffer_yw.gif\" height=3>
      <tr>
        <td></td>
      </tr>
    </table>
    "
    ;

    include
    "../guts/_ftr.php";

    ?>
    Reply With Quote
      #10  
    Old 01-21-2005, 01:50 PM
    NogDog's Avatar
    NogDog NogDog is offline
    High Energy Magic Dept.
     
    Join Date: Aug 2004
    Location: Ankh-Morpork
    Posts: 14,867
    My "stab in the twilight" now is the lack of quotes around the array index:
    PHP Code:
    $result[error_msg]
    # should be:
    $result['error_msg']
    Take a look at http://us4.php.net/manual/en/language.types.array.php and scroll down to "Array do's and don'ts".
    __________________
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    Kindle Minds (blog about Amazon Kindle)
    Reply With Quote
      #11  
    Old 01-21-2005, 02:00 PM
    MeltedMonitor MeltedMonitor is offline
    Registered User
     
    Join Date: Apr 2003
    Posts: 34
    Yeah, that was the first thing I tried... but it had no effect. Maybe I will have to go though the entire script changing [variable] to ['variable'] to see if that works. (sigh) I have a feeling it is something more than that, but I will give it a shot.

    Darren
    Reply With Quote
      #12  
    Old 01-21-2005, 02:04 PM
    MeltedMonitor MeltedMonitor is offline
    Registered User
     
    Join Date: Apr 2003
    Posts: 34
    Yeah, gave it a shot and it didn't help. There were only two variable names throughout the script lacking quotes: 'error' and 'error_msg'. Fixed them and still getting the error message.

    Darren
    Reply With Quote
      #13  
    Old 01-25-2005, 12:27 PM
    MeltedMonitor MeltedMonitor is offline
    Registered User
     
    Join Date: Apr 2003
    Posts: 34
    bump -- $50 to whoever suggest a successful solution.
    Reply With Quote
      #14  
    Old 05-19-2005, 03:20 AM
    Marmeladov Marmeladov is offline
    Registered User
     
    Join Date: May 2005
    Posts: 1
    A late stab in the dark

    This is probably way too late, but i would suggest you try
    $results->error_msg instead of $results['error_msg']. As stated, a late stab in the dark, but if you still haven't solved this, it could be worth a try.
    Reply With Quote
      #15  
    Old 05-28-2006, 05:34 AM
    EstoEsUnMamey EstoEsUnMamey is offline
    Registered User
     
    Join Date: May 2006
    Posts: 1
    Thumbs up My Problem

    I had the same problem, here's the solution.

    If dump my array this is what i get:

    PHP Code:
    print_r($objRsUsr);
    Array
    (
        [
    0] => stdClass Object
            
    (
                [
    id] => 62
                
    [name] => Administrator
            
    )

        [
    1] => stdClass Object
            
    (
                [
    id] => 63
                
    [name] => Pablo Viquez
            
    )

    )
    If I do:

    PHP Code:
    echo $objRsUsr[0]['id'];
    Generates the error: "Cannot use object of type stdClass as array"

    This because an stdClass is not an array but an object. To access those values you can do it like this:

    PHP Code:
    // Direct
    echo $objRsUsrP[0]->name;
    // prints Administrator

    // Or iterate
    for($intI = 0; $int < count($objRsUsr); $intI++){
        echo
    $objRsUsrP[$intI]->name . "\n";
    }
    // Prints:
    Administrator
    Pablo Viquez
    Hope it answered your question
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 04:56 PM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.