Autor | Zpráva | ||
---|---|---|---|
sithius Profil * |
#1 · Zasláno: 1. 1. 2008, 14:02:15
Nevíte proč v tomto kódu jde diakritika dobře u informaci o filmu, ale u komentářů jde blbě?
-------------------------- kód: http://paste.jabbim.cz/1710 <?php include "templates/mysql.php"; ?> <?php mysql_select_db( "movieweb" ) or die ( mysql_error() ); function difference_calculation( $takings, $cost ) { $difference = $takings - $cost; if ( $difference < 0 ) { $difference = substr( $difference, 1 ); $font_color = 'red'; $takings_or_cost = "- " . $difference . " milionů USD"; } elseif ( $difference > 0 ) { $font_color ='green'; $takings_or_cost = $difference . " milionů USD"; } else { $font_color = 'blue'; $takings_or_cost = "Zisky pokryly náklady"; } return "<font color=\"$font_color\">" . $takings_or_cost . "</font>"; } function specify_director() { global $movie_director; global $director; $result_spec = mysql_query( "SELECT people_fullname FROM people WHERE people_id='$movie_director'" ) or die( mysql_error() ); $row_spec = mysql_fetch_array( $result_spec ); extract( $row_spec ); $director = $people_fullname; } function specify_leadactor() { global $movie_leadactor; global $leadactor; $result_spec = mysql_query( "SELECT people_fullname FROM people WHERE people_id='$movie_leadactor'" ) or die( mysql_error() ); $row_spec = mysql_fetch_array( $result_spec ); extract( $row_spec ); $leadactor = $people_fullname; } $result_movie = mysql_query( "SELECT * FROM movie WHERE movie_id ='" . $_GET['id_filmu'] . "'" ) or die( mysql_error() ); $table_header=<<<EOD <tr> <th>Název filmu</th> <th>Rok uvedení</th> <th>Režisér</th> <th>V hlavní roli</th> <th>Délka filmu</th> <th>Úspěšnost filmu</th> </tr> EOD; $comment_header =<<<COMH <h3><center>Komentáře</center></h3> <tr> <th>datum vložení</th> <th>nadpis</th> <th>autor</th> <th>komentáře</th> <th>hodnocení</th> </tr> COMH; $result_comments = mysql_query( "SELECT * FROM comments WHERE comment_movie_id='" . $_GET['id_filmu'] . "' ORDER BY comment_date DESC" ) or die( mysql_error() ); while( $row = mysql_fetch_array( $result_comments ) ) { $comment_symptom = 1; $comment_name[] = $row['comment_name']; $commenter_name[] = ucwords( $row['comment_commenter_name'] ); $comment[] = $row['comment_comment']; $comment_date[] = $row['comment_date']; $comment_rating[] = comment_rating( $row['comment_rating'] ); } function comment_rating( $comment_rating ) { for ( $i=0; $i<$comment_rating; $i++ ) { $comment_rating_img .= "<img src='img/star.png'>"; } return $comment_rating_img; } $i = 0; while ($i<sizeof( $comment )) { $comment_details .=<<<EOD <tr> <td width='15%' valign='top' align='center'>$comment_date[$i]</td> <td width='15%' valign='top' align='center'>$comment_name[$i]</td> <td width='10%' valign='top' align='center'>$commenter_name[$i]</td> <td width='40%' valign='top'>$comment[$i]</td> <td width='20%' valign='top' align='center'>$comment_rating[$i]</td> </tr> EOD; $i++; } while ( $row = mysql_fetch_array( $result_movie ) ) { $movie_name = $row['movie_name']; $movie_director = $row['movie_director']; $movie_leadactor = $row['movie_leadactor']; $movie_year = $row['movie_year']; $movie_time = $row['movie_time'] . " minut"; $movie_takings = $row['movie_takings']; $movie_cost = $row['movie_cost']; } specify_director(); specify_leadactor(); $movie_prosperous = difference_calculation( $movie_takings, $movie_cost ); $header =<<<HEADER <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1250" /> <title>Podrobnosti o filmu $movie_name</title> </head> <body> HEADER; $movie_details =<<<DETAILS <table width='70%' border='0' cellspacing='0' cellpadding='0' align='center'> <tr> <th colspan='6'><u><h2>Podrobnosti filmu $movie_name</h2></u></th> </tr> $table_header <tr> <td width='25%' align='center'>$movie_name</td> <td align='center'>$movie_year</td> <td align='center'>$director</td> <td align='center'>$leadactor</td> <td align='center'>$movie_time</td> <td align='center'>$movie_prosperous</td> </tr> </table> <br /> <br /> DETAILS; if ( $comment_symptom ) { $movie_details .=<<<EOD <table width='95%' cellspacing='2' cellpadding='20' align='center'> $comment_header $comment_details </table> EOD; } $footer =<<<FOOTER </body> </html> FOOTER; $main =<<<MAIN $header $movie_details $footer MAIN; echo $main; ?> |
||
Smajlix Profil * |
#2 · Zasláno: 1. 1. 2008, 16:21:53
Zdravim,
kód jsem nečetl celý, ale: 1. Zkus dát po připojení k databázi: mysql_query("SET NAMES 'utf8'"); utf8 nahraď svým kódováním například Windows-1250 je cp1250. 2. Nepoužívej HEREDOC, je to kurevsky (pardon za ten výraz) pomalé. Nejrychlější jsou apostrofy, po nich uvozovky, pak dlouh onic a pak je HEREDOC který používáš ty. |
||
sithius Profil * |
#3 · Zasláno: 1. 1. 2008, 18:13:26
ad heredoc - učí mě to tak v knížce, nevím co je lepší a co horší... každopádně s tím něco zkusím.
ad kódování - nefunguje... chybu to žádnou nevypisuje, ale prostě to nefunguje... |
||
Smajlix Profil * |
#4 · Zasláno: 1. 1. 2008, 18:32:18
tak s tím kódováním netuchám.. nechceš mi poslat linky kde ten kód běží??
potřeboval bych vidět output, abych věděl co a jak. |
||
pEeLL Profil |
#5 · Zasláno: 1. 1. 2008, 18:59:15
je divne ze u jedne tabulky ti to jde a u druhe ne
nemas v databazi kazdou tabulku v jinem kodovani? pokud ne zkuz jeste to mysql_query( "SET NAMES 'utf8'" ) dat pred INSERT a zkus znovu neco ulozit. |
||
sithius Profil * |
#6 · Zasláno: 2. 1. 2008, 05:15:45
tak jsem tabulku dropnul a zas přidal a už to funguje... tak nevím kde byla chyba...
|
||
Joker Profil |
#7 · Zasláno: 2. 1. 2008, 08:11:44
sithius
tak nevím kde byla chyba Řekl bych, že data do té předchozí tabulky byla naplněna ve špatném kódování. |
||
Časová prodleva: 16 let
|
0