josef23 0 Denunciar post Postado Março 22, 2015 Boa tarde,Criei uma galeria gerenciável, com PHP e administração e BD mysql, ocorre que os caracteres acentuados ficam todos deformados, apresentando caracteres como @&Ã, na parte que apresenta a página que o visitante vê consegui arramar com:No script que faz a comunicação com o BD@mysql_select_db("$this->dbname");#o que acrescenteimysql_query("SET NAMES 'utf8'");mysql_query('SET character_set_connection=utf8');mysql_query('SET character_set_client=utf8');mysql_query('SET character_set_results=utf8');#fimMas a parte administrativa após digitar os dados fica tudo com estes caracteres estranhos...e no BD também.Alguma dica,Grato Compartilhar este post Link para o post Compartilhar em outros sites
lokaodomau 61 Denunciar post Postado Março 22, 2015 Qual o charset da tabale? (SHOW TABLE STATUS) Compartilhar este post Link para o post Compartilhar em outros sites
giesta 29 Denunciar post Postado Março 23, 2015 Dados são sempre dados, o que muda é como vc os exibe, e isso é defino no charset da página. Compartilhar este post Link para o post Compartilhar em outros sites
josef23 0 Denunciar post Postado Março 23, 2015 Obrigado por responder: charset da tabale?: UTF8_unicode_c , latin1_swedish_c, Mas acho que o problema é apenas em um arquivo que no administrativo ele mostra errado os caracteres, Vou tentar ver o erro, se não conseguir posto aqui, para ajuda Grato Obrigado, consegui arrumar a maioria, mas ficou um que não consegui, se alguem puder me ajudar... <?php @header( "Content-Type: text/html; charset=ISO-8859-1", true ); require_once '../database/mysql.php'; require_once '../class/Session.class.php'; $db = new Mysql; $sid = new Session; $sid->start(); if ( !$sid->check() ) { @header( 'Location: login.php' ); } if ( isset( $_GET['create'] ) && !empty( $_POST['new'] ) ) { $album_name = utf8_encode( trim( preg_replace( '/\s+/', ' ', $_POST['new'] ) ) ); $album_categoria = $_POST['album_categoria']; if ( $album_name != "" ) { $db->query( "insert into albuns (album_name,album_categoria) values ('$album_name',$album_categoria);" ); $album_id = mysql_insert_id(); @header( "Location: album.php?edit=$album_id" ); } } if ( isset( $_GET['delete'] ) && !empty( $_GET['delete'] ) ) { $album_id = $_GET['delete']; $db->query( "select * from fotos where foto_album = $album_id;" )->fetchAll(); if ( $db->rows >= 1 ) { foreach ( $db->data as $foto ) { $f = ( object ) $foto; $file = "../fotos/$f->foto_url"; if ( file_exists( $file ) ) { @unlink( $file ); } } } $db->query( "delete from albuns where album_id = $album_id" ); @header( "Location: album.php" ); } ?> <!DOCTYPE html> <html> <head> <title>Dream Gallery - Admin</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <link href="tpl/css/all.css" rel="stylesheet" type="text/css"> <link href="tpl/css/960_12.css" rel="stylesheet" type="text/css"> <link href="tpl/css/simple-lists.css" rel="stylesheet" type="text/css"> <link href="tpl/css/reset.css" rel="stylesheet" type="text/css"> <link href="tpl/css/common.css" rel="stylesheet" type="text/css"> <link href="tpl/css/standard.css" rel="stylesheet" type="text/css"> <link href="tpl/css/form.css" rel="stylesheet" type="text/css" /> <link href="tpl/css/simple-lists.css" rel="stylesheet" type="text/css" /> <link href="tpl/css/block-lists.css" rel="stylesheet" type="text/css" /> <link href="tpl/css/table.css" rel="stylesheet" type="text/css" /> <link href="../css/admin.css" rel="stylesheet" type="text/css" /> <!-- Generic libs --> <script type="text/javascript" src="tpl/js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="tpl/js/html5.js"></script> <script type="text/javascript" src="tpl/js/old-browsers.js"></script> <!-- Template core functions --> <script type="text/javascript" src="tpl/js/common.js"></script> <script type="text/javascript" src="tpl/js/jquery.tip.js"></script> <script type="text/javascript" src="tpl/js/standard.js"></script> <!--[if lte IE 8]><script type="text/javascript" src="tpl/js/standard.ie.js"></script><![endif]--> <script src="http://code.jquery.com/ui/1.8.23/jquery-ui.min.js"></script> <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery-ui.css" type="text/css" media="all" /> <link href="uploadfy/css/uploadify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="uploadfy/js/swfobject.js"></script> <script type="text/javascript" src="uploadfy/js/jquery.uploadify.v2.1.4.min.js"></script> <script src="js/jquery.scrollto.js" type="text/javascript"></script> <script type="text/javascript" src="js/album.js"></script> </head> <body> <div id="status-bar"> <div class="container_12"> <ul id="status-infos"> <li class="spaced">Dream Gallery :: <strong> Rafael Clares</strong></li> </ul> </div> </div> <div id="wrap" class="container_12"> <div class="grid_12"> <p> </p> <div class="block-border"> <div class="block-content"> <h1>Área Restrita - Álbuns <?php if ( isset( $_GET ) && !empty( $_GET ) ) { ?> <a href="album.php" class="with-tip" title="Todos os Álbuns"> <img src="tpl/images/back_blue.png" width="16" height="16"> Voltar </a> <?php } ?> </h1> <div class="block-controls"> <ul class="controls-tabs js-tabs with-children-tip"> <li><a href="index.php" title="Home"> <img src="tpl/images/icons/home.png" width="24" height="24"></a> </li> <li><a href="categoria.php" title="Categorias"> <img src="tpl/images/icons/category.png" width="24" height="24"></a> </li> <li class="current"><a href="album.php" title="Álbuns"> <img src="tpl/images/icons/gallery.png" width="24" height="24"></a> </li> <li><a href="video.php" title="Vídeos"> <img src="tpl/images/icons/video.png" width="24" height="24"></a> </li> <li><a href="agenda.php" title="Eventos"> <img src="tpl/images/icons/calendar.png" width="24" height="24"></a> </li> <li><a href="usuario.php" title="Usuários"> <img src="tpl/images/icons/users.png" width="24" height="24"></a> </li> <li><a href="login.php?logout=true" title="Logout"> <img src="tpl/images/icons/logout-gray.png" width="24" height="24"></a> </li> </ul> </div> <div id="home" style="min-height: 675px !important; overflow-y:auto !important;"> <p> </p> <?php if ( isset( $_GET['edit'] ) ) { $album_id = $_GET['edit']; ?> <script type="text/javascript"> $(document).ready(function() { $('#fupload').uploadify({ 'uploader' : 'uploadfy/js/uploadify.swf', 'script' : 'upload.php?album_id=<?= $album_id ?>', 'cancelImg' : 'uploadfy/js/cancel.png', 'folder' : 'fotos', 'auto' : true, 'multi' : true, 'buttonText' : 'Upload', 'sizeLimit' : 100002400, 'width' : 186, 'height' : 55, //'queueSizeLimit' : 10, 'uploadLimit' : 1, 'fileExt' : '*.jpg;*.gif;*.png;*.bmp;*.jpeg', 'fileDesc' : 'Imagens (JPG, GIF, PNG, BMP)', 'buttonImg' : '../images/upload.png', 'onAllComplete': function(event, queueID, fileObj,response){ window.location = 'album.php?edit=<?= $album_id ?>'; }, 'onComplete': function(event, queueID, fileObj,response){ var response = $.parseJSON(response); //alert(response) } }) }) </script> <?php $db->query( "select * from albuns where album_id = $album_id" )->fetchAll(); if ( $db->rows >= 1 ) { $album_name = utf8_decode( $db->data[0]['album_name'] ); //$album_name = $db->data[0]['album_name']; $album_id = $db->data[0]['album_id']; $album_categoria = $db->data[0]['album_categoria']; ?> <div class="box-album"> <ul class="box-album-head" style="width: 101%; margin:0; margin-bottom: 20px; padding: 0 !important"> <p class="one-line-input grey-bg with-padding"> <span class="relative"> <label for="new">Categoria do Álbum</label> <select name="album_categoria" id="album_categoria"> <?php $db->query( "select * from categorias order by categoria_name asc" )->fetchAll(); if ( $db->rows >= 1 ) { $categorias = $db->data; foreach ( $categorias as $cat ) { $c = ( object ) $cat; //$c->categoria_name = utf8_decode( $c->categoria_name ); if ( $c->categoria_id == $album_categoria ) { ?> <option selected="selected" value="<?= $c->categoria_id ?>"><?= $c->categoria_name ?></option> <?php } else { ?> <option value="<?= $c->categoria_id ?>"><?= $c->categoria_name ?></option> <?php } } } ?> </select> </span> </p> <p class="one-line-input grey-bg with-padding"> <span class="relative"> <label for="<?= $album_id ?>">Nome do Álbum</label> <input type="text" name="album_name" maxlength="74" id="<?= $album_id ?>" class="album_name with-tip" title="Nome do Álbum" value="<?= $album_name ?>" /> <button class="grey updateAlbumName">Atualizar</button> </span> </p> </ul> <span class="align-right btn-upload"> <input id="fupload" name="upload" type="file" class="hides" /> </span> <?php $db->query( "select * from fotos join albuns on (album_id = foto_album) where foto_album = $album_id order by foto_pos asc" )->fetchAll(); if ( $db->rows >= 1 ) { $fotos = $db->data; echo "<ul class=\"sortable\" style=\"list-style-type: none; margin: 0; padding: 0;\">"; foreach ( $fotos as $foto ) { $f = ( object ) $foto; $f->foto_caption = utf8_decode( $f->foto_caption ); echo "<li class=\"lisort\" id=\"item_$f->foto_id\">"; if ( $f->foto_caption == "" ) { $f->foto_caption = ""; } echo '<ul class="box-foto-edit extended-list ">' . "\n"; echo "<li>" . "\n"; ?> <ul class="mini-menu with-children-tips"> <li><a href="javascript:void(0)" title="Atualizar" id="<?= $f->foto_id ?>" album="<?= $album_id ?>" class="refresh with-tip tip-top"><img src="tpl/images/icons/refresh.png" width="16" height="16"></a></li> <li><a href="javascript:void(0)" title="Definir Capa" id="<?= $f->foto_id ?>" album="<?= $album_id ?>" class="cover with-tip tip-top"><img src="tpl/images/icons/photo.png" width="16" height="16"></a></li> <li><a href="javascript:void(0)" title="Remover" id="<?= $f->foto_id ?>" class="delete with-tip tip-top"><img src="tpl/images/cross-circle.png" width="16" height="16"></a></li> </ul> <img class="pic with-tip tip-left" title="mover posição" src="../thumb.php?img=fotos/<?= $f->foto_url ?>" width="172" height="140" /> <input type="text" class="with-tip foto_caption" id="f_<?= $f->foto_id ?>" value="<?= $f->foto_caption ?>" maxlength="74" title="Info 1" /> <!-- <input type="text" class="with-tip tip-bottom foto_info" id="if_<?= $f->foto_id ?>" value="<?= $f->foto_info ?>" maxlength="15" title="Info 2" /> --> <?php echo "</li>\n"; echo "</ul>\n"; echo '</li>' . "\n"; } echo '</ul>'; } } echo "</div>"; } else { ?> <div class="box-album"> <form name="f" action="album.php?create=true" method="post"> <ul class="box-album-head" style="width: 101%; margin:0; margin-bottom: 20px; padding: 0 !important"> <p class="one-line-input grey-bg with-padding"> <span class="relative"> <label for="new">Categoria do Álbum</label> <select name="album_categoria" id="album_categoria" style="width:663px !important"> <?php $db->query( "select * from categorias order by categoria_name asc" )->fetchAll(); if ( $db->rows >= 1 ) { $categorias = $db->data; foreach ( $categorias as $cat ) { $c = ( object ) $cat; //$c->categoria_name = utf8_decode( $c->categoria_name ); ?> <option value="<?= $c->categoria_id ?>"><?= $c->categoria_name ?></option> <?php } } ?> </select> </span> </p> <p class="one-line-input grey-bg with-padding"> <span class="relative"> <label for="new">Nome do Álbum</label> <input type="text" name="new" id="new" maxlength="74" class="album_name with-tip" title="Nome do Álbum" /> <button class="grey">Criar</button> </span> </p> </ul> </form> </div> <table class="table w-all" id="tbl_list_serv" style="width: 100%" cellspacing="0"> <thead> <tr> <th width="10">ID</th> <th>Álbum</th> <th>Categoria</th> <th width="60">Fotos</th> <th width="50">Ações</th> </tr> </thead> <tbody class="sortableAlbum"> <?php $page = 0; $perpage = 10; $current = 1; if ( isset( $_GET['page'] ) ) { $current = $_GET['page']; $page = $perpage * $_GET['page'] - $perpage; if ( $_GET['page'] == 1 ) { $page = 0; } } $db->query( "select * from categorias join albuns on (album_categoria = categoria_id)" )->fetchAll(); $total = $db->rows; $link = ''; if ( $db->rows > $perpage ) { $link = "<ul class=\"controls-buttons\" style=\"float:left; width:99%;\">\n"; $prox = "javascript:;"; $ant = "javascript:;"; if ( $current >= 2 ) { $ant = "album.php?page=" . ($current - 1); } if ( $current >= 1 && $current < ($total / $perpage) ) { $prox = "album.php?page=" . ($current + 1); } $link .= '<li><a href="' . $ant . '" title="Anterior"><img src="tpl/images/navigation-180.png" width="16" height="16">Ant</a></li>'; $from = round( $total / $perpage ) + 1; for ( $i = 1; $i <= $from; $i++ ) { if ( $current == $i ) { $link .= "<li><a class=\"current\" href=\"album.php?page=$i\"><b>$i</b></a></li>\n"; } else { $link .= "<li><a href=\"album.php?page=$i\"><b>$i</b></a></li>\n"; } } $link .= '<li><a href="' . $prox . '" title="Próxima"><img src="tpl/images/navigation.png" width="16" height="16">Prox</a></li>'; $link .= "</ul>\n"; $link .= "<ul style=\"float:left;margin-left:7px;\">\n"; $link .= "<p><a class=\"button\" href=\"album.php?order\">Mostrar Todas para Ordenar</a></p>\n"; $link .= "</ul>\n"; } if ( isset( $_GET['order'] ) ) { $page = 0; $perpage = $total; $link = ''; } $db->query( "select * from categorias join albuns on (album_categoria = categoria_id) order by album_pos asc, categoria_name asc LIMIT $page,$perpage" )->fetchAll(); //$db->query( "select * from categorias join albuns on (album_categoria = categoria_id) order by album_id asc LIMIT $page,$perpage" )->fetchAll(); if ( $db->rows >= 1 ) { $albuns = $db->data; foreach ( $albuns as $album ) { $alb = ( object ) $album; //$alb->album_name = utf8_decode( $alb->album_name ); $alb->album_name = $alb->album_name; $db->query( "select * from fotos where foto_album = $alb->album_id" )->fetchAll(); echo "<tr id=\"item_$alb->album_id\">"; echo "<td class=\"cursor-move with-tip\" title=\"mudar ordem\"> $alb->album_id </td>"; echo "<td class=\"cursor-move with-tip\" title=\"mudar ordem\"> $alb->album_name </td>"; echo "<td class=\"cursor-move with-tip\" title=\"mudar ordem\"> $alb->categoria_name </td>"; echo "<td class=\"cursor-move with-tip\" title=\"mudar ordem\"> $db->rows </td>"; ?> <td> <a class="with-tip edit" title="editar álbum" href="album.php?edit=<?= $alb->album_id ?>"> <img src="tpl/images/pencil.png" width="16" height="16"> </a> <a class="with-tip deleteAlbum" title="remover álbum" id="<?= $alb->album_id ?>" href="javascript:void(0)"> <img src="tpl/images/cross-circle.png" width="16" height="16"> </a> </td> <?php echo "</tr>"; } } ?> <tfoot> <tr> <th> </th> <th> </th> <th> </th> <th> </th> <th> </th> </tr> </tfoot> </table> <? echo $link; ?> </div> <?php } ?> <p> </p> </div> <p> </p> </div> </div> </div> <p id="footer"> </p> </body> </html> Compartilhar este post Link para o post Compartilhar em outros sites
Fernando C 128 Denunciar post Postado Março 23, 2015 tente descomentar essa linha: @header( "Content-Type: text/html; charset=ISO-8859-1", true ); Compartilhar este post Link para o post Compartilhar em outros sites
josef23 0 Denunciar post Postado Março 23, 2015 Obrigado por responder, tirei @ mas não resolveu... Grato Compartilhar este post Link para o post Compartilhar em outros sites
giesta 29 Denunciar post Postado Março 24, 2015 vou transferir para php. la eles terao mais capacidade de te ajudar, Compartilhar este post Link para o post Compartilhar em outros sites
BlackMix 15 Denunciar post Postado Março 24, 2015 Use utf8_encode( $seutextoaqui ); acho que resolve com isso. Compartilhar este post Link para o post Compartilhar em outros sites
josef23 0 Denunciar post Postado Março 24, 2015 Obrigado por responder, o script esta assim nesta linha: $album_name = utf8_encode( trim( preg_replace( '/\s+/', ' ', $_POST['new'] ) ) ); Tentei sua sugestão mas não funcionou. Grato Compartilhar este post Link para o post Compartilhar em outros sites
Kakashi_Hatake 267 Denunciar post Postado Março 24, 2015 :seta: PHP, HTML, MySQL - Charset Encoding Compartilhar este post Link para o post Compartilhar em outros sites