Object of class stdClass could not be converted to string

后端 未结 6 972
时光说笑
时光说笑 2020-12-01 11:45

I am having a problem with PHP at the moment, I am getting this error,

Object of class stdClass could not be converted to string the error occurs when

6条回答
  •  爱一瞬间的悲伤
    2020-12-01 12:23

    In General to get rid of

    Object of class stdClass could not be converted to string.

    try to use echo '

    '; print_r($sql_query); for my SQL Query got the result as 

    stdClass Object
    (
        [num_rows] => 1
        [row] => Array
            (
                [option_id] => 2
                [type] => select
                [sort_order] => 0
            )
    
        [rows] => Array
            (
                [0] => Array
                    (
                        [option_id] => 2
                        [type] => select
                        [sort_order] => 0
                    )
    
            )
    
    )
    

    In order to acces there are different methods E.g.: num_rows, row, rows

    echo $query2->row['option_id'];
    

    Will give the result as 2

提交回复
热议问题