Web Analytics Made Easy -
StatCounter Notice: Array to string conversion - CodingForum


No announcement yet.

Notice: Array to string conversion

  • Filter
  • Time
  • Show
Clear All
new posts

  • Notice: Array to string conversion

    Hi;everybody .I am required to fetch some data from db.But I am getting this error at this line
    Notice: Array to string conversion <span><?php echo ["konu_tarih"];?></span>

    what is wrong here?

    this is my code

    PHP Code:
    $islem = @$_GET["islem"];

    switch ($islem) {
        case "iletisim":
            echo "ddd";
        case "hakkimda":
            $v = $db->prepare("select * from konular");
            $m = $v->fetchAll(2);

            foreach ($m as $xx) {

                <div class="konu">
                    <h3><?php echo $xx["konu_baslik"]; ?></h3>
                   <h5>   Ekleyen : <?php echo $xx["konu_ekleyen"]; ?></h5>
                    <span><?php echo ["konu_tarih"];?></span>




  • #2
    The expression
    denotes an array containing a single string. I'm fairly sure that's not what you want. You probably mean
    This denotes an item of the $xx array.

    The code in general is weird. Why would you create a prepared statement and pass zero parameters to it? Simply call the query() method. What's up with the fetchAll(2)? If the 2 is supposed to specify the fetch mode, use one of the PDO constants instead (e.g. PDO::FETCH_ASSOC). Better yet, define a default fetch mode when you instantiate the PDO class so that you don't have to repeat it over and over again.


    • #3
      And get rid of the @. Don't suppress errors. Fix them.
      To save time, lets just assume I am almost never wrong.

      The XY Problem
      The XY problem is asking about your attempted solution (X) rather than your actual problem (Y). This leads to enormous amounts of wasted time and energy, both on the part of people asking for help, and on the part of those providing help.

      Make A Donation https://www.paypal.me/KevinRubio


      • #4
        Thank you so much


        • #5
          Never use select *

          You should always specify the exact fields you want to have returned so as to not expose fields you don't need to potential security holes.
          Learn Modern JavaScript - http://javascriptexample.net/
          Helping others to solve their computer problem at http://www.felgall.com/

          Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.