IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

CodeIgniter PHP Discussion :

Array to string conversion


Sujet :

CodeIgniter PHP

  1. #1
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2011
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juillet 2011
    Messages : 44
    Points : 19
    Points
    19
    Par défaut Array to string conversion
    Salut à tous, voila je code un site sous codeigniter, mais j'ai un problème dans mon model !

    je fait un script de personne en ligne donc voici mon model :


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    <?php
    public function Online() {
     
            $DB3 = $this->load->database('char', TRUE);
     
            $DB3 -> select('*');
      	    $DB3 -> from('characters');
      	    $DB3 -> where('online', '1');
     
            $query = $DB3 -> get();
     
            return $query->result_array();
     
        }
    et mon erreur :

    A PHP Error was encountered

    Severity: Notice

    Message: Array to string conversion

    Filename: views/stats.php

    Line Number: 11
    Array
    merci de votre aide, surtout que ça fait 3h que je cherche

  2. #2
    Expert éminent
    Avatar de Benjamin Delespierre
    Profil pro
    Développeur Web
    Inscrit en
    Février 2010
    Messages
    3 929
    Détails du profil
    Informations personnelles :
    Âge : 36
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Février 2010
    Messages : 3 929
    Points : 7 762
    Points
    7 762
    Par défaut
    Il s'agit d'une erreur classique de conversion implicite de tableau en chaîne de caractère que CodeIgniter à attrapé pour toi. Regarde dans views/stats.php s'il n'y a pas un endroit où une référence de type array est utilisée dans une chaîne.

  3. #3
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2011
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juillet 2011
    Messages : 44
    Points : 19
    Points
    19
    Par défaut
    Non du tous voici mon fivhier views :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    <div id="news">
        <div class="box_title">
            <h4>Statistique</h4>
        </div>
        <div class="total">
            <div class="box_title">
                Joueurs en ligne
            </div>
            <div class="accordion-inner box_content">
                <ul>
                    <li>Total : <?php echo $online; ?></li>
                    <li>Horde : 450</li>
                    <li>Alliance : 400</li>
                </ul>
            </div>
        </div>
        <div class="total">
            <div class="box_title">
                Membre
            </div>
            <div class="accordion-inner box_content">
                <ul>
                    <li>Total : <?php echo $inscrit; ?></li>
                    <li>Bannie : <?php echo $banniecompte + $bannieip; ?></li>
                </ul>
            </div>
        </div>
        <div class="total">
            <div class="box_title">
                Autre
            </div>
            <div class="accordion-inner box_content">
                <ul>
                    <li>Uptime : <?php echo $uptime; ?></li>
                    <li>Maximum de joueurs en ligne : <?php echo $maxonliner; ?></li>
                </ul>
            </div>
        </div>
    </div>

  4. #4
    Modérateur

    Avatar de MaitrePylos
    Homme Profil pro
    DBA
    Inscrit en
    Juin 2005
    Messages
    5 496
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : Belgique

    Informations professionnelles :
    Activité : DBA
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 496
    Points : 12 596
    Points
    12 596
    Par défaut
    Essaye quelque chose comme ceci, pour voir

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
     $DB3 = $this->load->database('char', TRUE);
     $query = $DB3->query("SELECT * FROM characters WHERE online = 1");
           if ($query->num_rows() < 0){
              show_error('Database is empty!');
           }else{
              return $query->result();
    }

  5. #5
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2011
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juillet 2011
    Messages : 44
    Points : 19
    Points
    19
    Par défaut
    Rien ne change :/ (merci de ton aide :p)

  6. #6
    Expert éminent
    Avatar de Benjamin Delespierre
    Profil pro
    Développeur Web
    Inscrit en
    Février 2010
    Messages
    3 929
    Détails du profil
    Informations personnelles :
    Âge : 36
    Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Février 2010
    Messages : 3 929
    Points : 7 762
    Points
    7 762
    Par défaut
    Fais des var_dump sur les références que tu utilise dans ta vue pour voir laquelle pose problème.

  7. #7
    Modérateur

    Avatar de MaitrePylos
    Homme Profil pro
    DBA
    Inscrit en
    Juin 2005
    Messages
    5 496
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : Belgique

    Informations professionnelles :
    Activité : DBA
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 496
    Points : 12 596
    Points
    12 596
    Par défaut
    Ceci donne quoi
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     <li>Total : <?php echo var_dump($online); ?></li>
    @Filleul : Line Number: 11 Array

  8. #8
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2011
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juillet 2011
    Messages : 44
    Points : 19
    Points
    19
    Par défaut
    Voici la longue réponse :
    array(4) { [0]=> object(stdClass)#22 (71) { ["guid"]=> string(3) "632" ["account"]=> string(3) "257" ["name"]=> string(8) "Smartise" ["race"]=> string(2) "10" ["class"]=> string(1) "5" ["gender"]=> string(1) "0" ["level"]=> string(2) "80" ["xp"]=> string(1) "0" ["money"]=> string(8) "81103296" ["playerBytes"]=> string(6) "131840" ["playerBytes2"]=> string(8) "33554437" ["playerFlags"]=> string(1) "0" ["position_x"]=> string(7) "7423.72" ["position_y"]=> string(8) "-530.573" ["position_z"]=> string(7) "1896.85" ["map"]=> string(3) "571" ["instance_id"]=> string(1) "0" ["instance_mode_mask"]=> string(1) "0" ["orientation"]=> string(7) "5.39255" ["taximask"]=> string(39) "0 0 131072 4 0 0 1048576 0 0 0 0 0 0 0 " ["online"]=> string(1) "1" ["cinematic"]=> string(1) "1" ["totaltime"]=> string(4) "3424" ["leveltime"]=> string(4) "3424" ["logout_time"]=> string(10) "1345677813" ["is_logout_resting"]=> string(1) "0" ["rest_bonus"]=> string(1) "0" ["resettalents_cost"]=> string(6) "200000" ["resettalents_time"]=> string(10) "1345677121" ["trans_x"]=> string(1) "0" ["trans_y"]=> string(1) "0" ["trans_z"]=> string(1) "0" ["trans_o"]=> string(1) "0" ["transguid"]=> string(1) "0" ["extra_flags"]=> string(1) "4" ["stable_slots"]=> string(1) "0" ["at_login"]=> string(1) "0" ["zone"]=> string(2) "67" ["death_expire_time"]=> string(1) "0" ["taxi_path"]=> string(0) "" ["arenaPoints"]=> string(1) "0" ["totalHonorPoints"]=> string(1) "0" ["todayHonorPoints"]=> string(1) "0" ["yesterdayHonorPoints"]=> string(1) "0" ["totalKills"]=> string(1) "0" ["todayKills"]=> string(1) "0" ["yesterdayKills"]=> string(1) "0" ["chosenTitle"]=> string(1) "0" ["knownCurrencies"]=> string(1) "0" ["watchedFaction"]=> string(10) "4294967295" ["drunk"]=> string(1) "0" ["health"]=> string(4) "4027" ["power1"]=> string(5) "38653" ["power2"]=> string(1) "0" ["power3"]=> string(1) "0" ["power4"]=> string(3) "100" ["power5"]=> string(1) "0" ["power6"]=> string(1) "0" ["power7"]=> string(1) "0" ["latency"]=> string(2) "50" ["speccount"]=> string(1) "1" ["activespec"]=> string(1) "0" ["exploredZones"]=> string(1408) "4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 " ["equipmentCache"]=> string(185) "200050 0 39282 0 200053 0 53 0 200051 0 200055 0 200052 0 200057 0 200056 0 200054 0 50313 0 39231 0 45466 0 45466 0 39272 0 48408 0 50309 0 49185 0 0 0 38082 0 38082 0 38082 0 38082 0 " ["ammoId"]=> string(1) "0" ["knownTitles"]=> string(16) "0 32768 0 0 0 0 " ["actionBars"]=> string(2) "15" ["grantableLevels"]=> string(1) "0" ["deleteInfos_Account"]=> NULL ["deleteInfos_Name"]=> NULL ["deleteDate"]=> NULL } [1]=> object(stdClass)#25 (71) { ["guid"]=> string(3) "694" ["account"]=> string(3) "287" ["name"]=> string(7) "Salakis" ["race"]=> string(1) "5" ["class"]=> string(1) "5" ["gender"]=> string(1) "0" ["level"]=> string(2) "80" ["xp"]=> string(1) "0" ["money"]=> string(10) "1992386700" ["playerBytes"]=> string(8) "16845059" ["playerBytes2"]=> string(8) "33554434" ["playerFlags"]=> string(4) "3072" ["position_x"]=> string(7) "6660.05" ["position_y"]=> string(8) "-202.198" ["position_z"]=> string(7) "950.989" ["map"]=> string(3) "571" ["instance_id"]=> string(1) "0" ["instance_mode_mask"]=> string(2) "48" ["orientation"]=> string(7) "5.85508" ["taximask"]=> string(40) "1024 0 0 4 0 0 1048576 0 0 0 2048 0 0 0 " ["online"]=> string(1) "1" ["cinematic"]=> string(1) "1" ["totaltime"]=> string(6) "412510" ["leveltime"]=> string(6) "412510" ["logout_time"]=> string(10) "1346683608" ["is_logout_resting"]=> string(1) "0" ["rest_bonus"]=> string(1) "0" ["resettalents_cost"]=> string(6) "500000" ["resettalents_time"]=> string(10) "1346520568" ["trans_x"]=> string(1) "0" ["trans_y"]=> string(1) "0" ["trans_z"]=> string(1) "0" ["trans_o"]=> string(1) "0" ["transguid"]=> string(1) "0" ["extra_flags"]=> string(1) "4" ["stable_slots"]=> string(1) "0" ["at_login"]=> string(1) "0" ["zone"]=> string(2) "67" ["death_expire_time"]=> string(10) "1346679397" ["taxi_path"]=> string(0) "" ["arenaPoints"]=> string(3) "187" ["totalHonorPoints"]=> string(4) "6704" ["todayHonorPoints"]=> string(5) "11139" ["yesterdayHonorPoints"]=> string(4) "5456" ["totalKills"]=> string(3) "495" ["todayKills"]=> string(1) "9" ["yesterdayKills"]=> string(1) "0" ["chosenTitle"]=> string(1) "0" ["knownCurrencies"]=> string(9) "134477824" ["watchedFaction"]=> string(10) "4294967295" ["drunk"]=> string(1) "0" ["health"]=> string(7) "1096640" ["power1"]=> string(5) "60343" ["power2"]=> string(1) "0" ["power3"]=> string(1) "0" ["power4"]=> string(3) "100" ["power5"]=> string(1) "0" ["power6"]=> string(1) "0" ["power7"]=> string(1) "0" ["latency"]=> string(2) "60" ["speccount"]=> string(1) "2" ["activespec"]=> string(1) "0" ["exploredZones"]=> string(1408) "4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 " ["equipmentCache"]=> string(187) "41854 0 51894 0 41869 0 42370 0 41859 0 41881 0 41864 0 41885 3606 41893 0 41874 0 51558 0 50642 0 45466 0 45466 0 39272 0 48408 0 50309 0 49185 0 19031 0 38082 0 38082 0 38082 0 38082 0 " ["ammoId"]=> string(5) "52021" ["knownTitles"]=> string(16) "0 32768 0 0 0 0 " ["actionBars"]=> string(1) "7" ["grantableLevels"]=> string(1) "0" ["deleteInfos_Account"]=> NULL ["deleteInfos_Name"]=> NULL ["deleteDate"]=> NULL } [2]=> object(stdClass)#26 (71) { ["guid"]=> string(4) "1339" ["account"]=> string(3) "334" ["name"]=> string(9) "Féandral" ["race"]=> string(1) "3" ["class"]=> string(1) "8" ["gender"]=> string(1) "1" ["level"]=> string(2) "80" ["xp"]=> string(1) "0" ["money"]=> string(7) "6136273" ["playerBytes"]=> string(9) "100860928" ["playerBytes2"]=> string(8) "34013186" ["playerFlags"]=> string(4) "2048" ["position_x"]=> string(7) "6663.88" ["position_y"]=> string(8) "-205.883" ["position_z"]=> string(6) "949.66" ["map"]=> string(3) "571" ["instance_id"]=> string(1) "0" ["instance_mode_mask"]=> string(1) "1" ["orientation"]=> string(7) "5.31127" ["taximask"]=> string(35) "34 0 0 8 0 0 1048576 0 0 0 0 0 0 0 " ["online"]=> string(1) "1" ["cinematic"]=> string(1) "1" ["totaltime"]=> string(5) "42966" ["leveltime"]=> string(5) "42966" ["logout_time"]=> string(10) "1346748274" ["is_logout_resting"]=> string(1) "0" ["rest_bonus"]=> string(1) "0" ["resettalents_cost"]=> string(1) "0" ["resettalents_time"]=> string(1) "0" ["trans_x"]=> string(1) "0" ["trans_y"]=> string(1) "0" ["trans_z"]=> string(1) "0" ["trans_o"]=> string(1) "0" ["transguid"]=> string(1) "0" ["extra_flags"]=> string(1) "4" ["stable_slots"]=> string(1) "0" ["at_login"]=> string(1) "0" ["zone"]=> string(2) "67" ["death_expire_time"]=> string(10) "1346578869" ["taxi_path"]=> string(0) "" ["arenaPoints"]=> string(2) "75" ["totalHonorPoints"]=> string(4) "8809" ["todayHonorPoints"]=> string(1) "0" ["yesterdayHonorPoints"]=> string(4) "5435" ["totalKills"]=> string(2) "25" ["todayKills"]=> string(1) "0" ["yesterdayKills"]=> string(1) "4" ["chosenTitle"]=> string(3) "111" ["knownCurrencies"]=> string(6) "186432" ["watchedFaction"]=> string(1) "0" ["drunk"]=> string(1) "0" ["health"]=> string(7) "2396088" ["power1"]=> string(6) "252170" ["power2"]=> string(1) "0" ["power3"]=> string(1) "0" ["power4"]=> string(3) "100" ["power5"]=> string(1) "0" ["power6"]=> string(1) "0" ["power7"]=> string(1) "0" ["latency"]=> string(2) "36" ["speccount"]=> string(1) "2" ["activespec"]=> string(1) "0" ["exploredZones"]=> string(1408) "4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 " ["equipmentCache"]=> string(180) "29076 0 39282 0 29079 0 42370 0 29077 0 30895 0 29078 0 32239 0 32270 0 29080 0 50313 0 50313 0 45466 0 45466 0 39272 0 48414 0 0 0 49185 0 19031 0 38082 0 38082 0 38082 0 38082 0 " ["ammoId"]=> string(1) "0" ["knownTitles"]=> string(20) "0 32768 0 32768 0 0 " ["actionBars"]=> string(2) "15" ["grantableLevels"]=> string(1) "0" ["deleteInfos_Account"]=> NULL ["deleteInfos_Name"]=> NULL ["deleteDate"]=> NULL } [3]=> object(stdClass)#27 (71) { ["guid"]=> string(4) "1402" ["account"]=> string(1) "4" ["name"]=> string(6) "Druidd" ["race"]=> string(1) "3" ["class"]=> string(2) "11" ["gender"]=> string(1) "0" ["level"]=> string(2) "80" ["xp"]=> string(1) "0" ["money"]=> string(8) "77983735" ["playerBytes"]=> string(6) "395014" ["playerBytes2"]=> string(8) "34013185" ["playerFlags"]=> string(1) "0" ["position_x"]=> string(7) "6658.23" ["position_y"]=> string(8) "-186.516" ["position_z"]=> string(7) "954.169" ["map"]=> string(3) "571" ["instance_id"]=> string(1) "0" ["instance_mode_mask"]=> string(1) "0" ["orientation"]=> string(8) "0.217303" ["taximask"]=> string(35) "32 0 0 8 0 0 1048576 0 0 0 0 0 0 0 " ["online"]=> string(1) "1" ["cinematic"]=> string(1) "1" ["totaltime"]=> string(5) "12005" ["leveltime"]=> string(5) "12005" ["logout_time"]=> string(10) "1346692605" ["is_logout_resting"]=> string(1) "0" ["rest_bonus"]=> string(1) "0" ["resettalents_cost"]=> string(5) "10000" ["resettalents_time"]=> string(10) "1346660368" ["trans_x"]=> string(1) "0" ["trans_y"]=> string(1) "0" ["trans_z"]=> string(1) "0" ["trans_o"]=> string(1) "0" ["transguid"]=> string(1) "0" ["extra_flags"]=> string(2) "36" ["stable_slots"]=> string(1) "0" ["at_login"]=> string(1) "0" ["zone"]=> string(2) "67" ["death_expire_time"]=> string(1) "0" ["taxi_path"]=> string(0) "" ["arenaPoints"]=> string(1) "0" ["totalHonorPoints"]=> string(1) "0" ["todayHonorPoints"]=> string(1) "0" ["yesterdayHonorPoints"]=> string(1) "0" ["totalKills"]=> string(1) "0" ["todayKills"]=> string(1) "0" ["yesterdayKills"]=> string(1) "0" ["chosenTitle"]=> string(1) "0" ["knownCurrencies"]=> string(1) "0" ["watchedFaction"]=> string(10) "4294967295" ["drunk"]=> string(1) "0" ["health"]=> string(6) "862810" ["power1"]=> string(5) "73022" ["power2"]=> string(1) "0" ["power3"]=> string(1) "0" ["power4"]=> string(3) "100" ["power5"]=> string(1) "0" ["power6"]=> string(1) "0" ["power7"]=> string(1) "0" ["latency"]=> string(2) "31" ["speccount"]=> string(1) "1" ["activespec"]=> string(1) "0" ["exploredZones"]=> string(1408) "4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 " ["equipmentCache"]=> string(143) "29098 0 0 0 29100 0 0 0 29087 0 28565 0 29088 0 28752 0 28453 0 29097 0 0 0 0 0 0 0 0 0 0 0 3661 0 0 0 0 0 0 0 38082 0 38082 0 38082 0 38082 0 " ["ammoId"]=> string(1) "0" ["knownTitles"]=> string(16) "0 32768 0 0 0 0 " ["actionBars"]=> string(1) "0" ["grantableLevels"]=> string(1) "0" ["deleteInfos_Account"]=> NULL ["deleteInfos_Name"]=> NULL ["deleteDate"]=> NULL } }

  9. #9
    Modérateur

    Avatar de MaitrePylos
    Homme Profil pro
    DBA
    Inscrit en
    Juin 2005
    Messages
    5 496
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : Belgique

    Informations professionnelles :
    Activité : DBA
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 496
    Points : 12 596
    Points
    12 596
    Par défaut
    Et donc c'est bien ce que te disait Benjamin.

    Tu essaye d'afficher via un echo , un tableau (qui est en fait la sortie de ta requête).

    Tu ne peux donc pas le faire, il te traiter ce tableau

    ceci sera plus claire pour toi

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     <li>Total : <pre><?php echo var_dump($online); ?></pre></li>

  10. #10
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2011
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juillet 2011
    Messages : 44
    Points : 19
    Points
    19
    Par défaut
    Ah d'accord excusez moi j'avais pas compris :p

    donc ça me retourne :

    array(7) {
    [0]=>
    object(stdClass)#22 (1) {
    ["guid"]=>
    string(3) "636"
    }
    [1]=>
    object(stdClass)#25 (1) {
    ["guid"]=>
    string(3) "694"
    }
    [2]=>
    object(stdClass)#26 (1) {
    ["guid"]=>
    string(4) "1339"
    }
    [3]=>
    object(stdClass)#27 (1) {
    ["guid"]=>
    string(4) "1391"
    }
    [4]=>
    object(stdClass)#28 (1) {
    ["guid"]=>
    string(4) "1431"
    }
    [5]=>
    object(stdClass)#29 (1) {
    ["guid"]=>
    string(4) "1473"
    }
    [6]=>
    object(stdClass)#30 (1) {
    ["guid"]=>
    string(4) "1474"
    }
    }
    je doit faire un foreach non ?

  11. #11
    Modérateur

    Avatar de MaitrePylos
    Homme Profil pro
    DBA
    Inscrit en
    Juin 2005
    Messages
    5 496
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : Belgique

    Informations professionnelles :
    Activité : DBA
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 496
    Points : 12 596
    Points
    12 596
    Par défaut
    Ben voila, maintenant vous savez pq il y avais une erreur.

    Reste plus qu'a la traiter.

    Bine à vous.

  12. #12
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2011
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juillet 2011
    Messages : 44
    Points : 19
    Points
    19
    Par défaut
    merci encors, mais j'ai fait mon foreach :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
                      <?php foreach($online as $result)
    {
    echo $result ,'<br/>';
    }
    ?>
    mais j'ai cette erreur :


    A PHP Error was encountered

    Severity: 4096

    Message: Object of class stdClass could not be converted to string

    Filename: views/stats.php

    Line Number: 14

    A PHP Error was encountered

    Severity: 4096

    Message: Object of class stdClass could not be converted to string

    Filename: views/stats.php

    Line Number: 14

    A PHP Error was encountered

    Severity: 4096

    Message: Object of class stdClass could not be converted to string

    Filename: views/stats.php

    Line Number: 14

    A PHP Error was encountered

    Severity: 4096

    Message: Object of class stdClass could not be converted to string

    Filename: views/stats.php

    Line Number: 14

    A PHP Error was encountered

    Severity: 4096

    Message: Object of class stdClass could not be converted to string

    Filename: views/stats.php

    Line Number: 14

    A PHP Error was encountered

    Severity: 4096

    Message: Object of class stdClass could not be converted to string

    Filename: views/stats.php

    Line Number: 14

    A PHP Error was encountered

    Severity: 4096

    Message: Object of class stdClass could not be converted to string

    Filename: views/stats.php

    Line Number: 14

    A PHP Error was encountered

    Severity: 4096

    Message: Object of class stdClass could not be converted to string

    Filename: views/stats.php

    Line Number: 14

  13. #13
    Modérateur

    Avatar de MaitrePylos
    Homme Profil pro
    DBA
    Inscrit en
    Juin 2005
    Messages
    5 496
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : Belgique

    Informations professionnelles :
    Activité : DBA
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 496
    Points : 12 596
    Points
    12 596
    Par défaut
    Heu je veux bien mais faut aussi faire un effort

    Le premier message disait qu'il n'arrivait pas a transformer un tableau en texte.
    Ici il dit le même message sauf que c'est pas un tableau mais une classe.

    Il faut donc un var_dump pour voir ce qui a dedans et le traiter.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    <?php foreach($online as $result)
    {
    echo'<pre>'.var_dump($result) ,'</pre>';
    }
    ?>

  14. #14
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2011
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juillet 2011
    Messages : 44
    Points : 19
    Points
    19
    Par défaut
    La il m'envoie :object(stdClass)#23 (1) { ["guid"]=> string(3) "619" }

    object(stdClass)#26 (1) { ["guid"]=> string(3) "694" }

    object(stdClass)#27 (1) { ["guid"]=> string(4) "1339" }

    object(stdClass)#28 (1) { ["guid"]=> string(4) "1391" }

    object(stdClass)#29 (1) { ["guid"]=> string(4) "1431" }

    object(stdClass)#30 (1) { ["guid"]=> string(4) "1473" }

    object(stdClass)#31 (1) { ["guid"]=> string(4) "1474" }

  15. #15
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2011
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juillet 2011
    Messages : 44
    Points : 19
    Points
    19
    Par défaut
    C'est bon j'ai trouver : <?php echo count($online); ?>

  16. #16
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2011
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juillet 2011
    Messages : 44
    Points : 19
    Points
    19
    Par défaut
    Par contre aprés j'ai une autre erreur que la je trouve pas non plus je comprend pas grand chose au tableau :p

    donc mon model :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    public function Max_Online() {
     
            $DB3 = $this->load->database('realmd', TRUE);
            $DB3 -> select('maxplayers');
    	    $DB3 -> from('uptime');
    	    $DB3 -> order_by('maxplayers', 'desc');
            $DB3 -> limit(1);
            $retourne = $DB3->get(); 
            return $retourne->result_array('maxplayers');
     
        }
     
    ma views :
     
    <li>Maximum de joueurs en ligne : <?php foreach($maxonliner as $result)
    {
    echo'<pre>'.var_dump($result) ,'</pre>';
    }
    ?>
    </li>
    mon résultat :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    array(1) { ["maxplayers"]=> string(2) "28" }

  17. #17
    Modérateur

    Avatar de MaitrePylos
    Homme Profil pro
    DBA
    Inscrit en
    Juin 2005
    Messages
    5 496
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 51
    Localisation : Belgique

    Informations professionnelles :
    Activité : DBA
    Secteur : Service public

    Informations forums :
    Inscription : Juin 2005
    Messages : 5 496
    Points : 12 596
    Points
    12 596
    Par défaut
    Faudrais alors lire un petit tuto sur les tableau, qui représente quand même une grosse partie de PHP.

    Dans ce cas, faites ceci

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    echo $result['maxplayers'] ;

  18. #18
    Membre à l'essai
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juillet 2011
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Nord (Nord Pas de Calais)

    Informations professionnelles :
    Activité : Développeur Web

    Informations forums :
    Inscription : Juillet 2011
    Messages : 44
    Points : 19
    Points
    19
    Par défaut
    Génial tous est regler merci beaucoup

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [PHP 5.6] PHP Notice: Array to string conversion
    Par beegees dans le forum Langage
    Réponses: 6
    Dernier message: 09/11/2015, 08h55
  2. [PDO] Array to string conversion et calcule d'après un code promotion
    Par Valadone dans le forum PHP & Base de données
    Réponses: 13
    Dernier message: 27/06/2015, 18h30
  3. [MySQL] PB : "Notice: Array to string conversion"
    Par moma586 dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 13/07/2012, 09h11
  4. [MySQL] Formulaire erreur Array to string conversion
    Par akamaru dans le forum PHP & Base de données
    Réponses: 7
    Dernier message: 19/12/2008, 11h02
  5. Réponses: 2
    Dernier message: 28/12/2007, 12h09

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo