Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Czysta strona po include
Maxie
post 1.06.2012, 21:56:10
Post #1





Grupa: Zarejestrowani
Postów: 82
Pomógł: 1
Dołączył: 19.10.2011

Ostrzeżenie: (0%)
-----


Otóż dopadła mnie chęć napisania strony o anime, ale jak to fajnie chęci może zburzyć jakiś głupi błąd. Otóż znam się już powierzchownie na PHP, ale takiego dziwnego problemu nigdy nie miałem. Otóż mam sobie dwa pliczki, "core.php" (jego treśćsmile.gif
  1. <?php
  2.  
  3. if(defined('include_perm')){
  4. header('Location: index.php?x=error');
  5. }
  6.  
  7. //to jest uzupełnione, ale nie podam WAM snitch.gif
  8. define('DBHOST', '');
  9. define('DBUSER', '');
  10. define('DBPASS', '');
  11. define('DBNAME', '');
  12.  
  13. function db_connect() {
  14. mysql_connect(DBHOST, DBUSER, DBPASS) or die('<h2>ERROR</h2> MySQL Server is not responding');
  15. mysql_select_db(DBNAME) or die('<h2>ERROR</h2> Cannot connect to specified database');
  16. }
  17.  
  18. function db_close() {
  19. }
  20.  
  21. function clear($text) {
  22. $text = stripslashes($text);
  23. }
  24. $text = trim($text);
  25. $text = mysql_real_escape_string($text);
  26. $text = htmlspecialchars($text);
  27. return $text;
  28. }
  29.  
  30. function codepass($password) {
  31. return sha1(md5($password).'#!%Rgd64');
  32. }
  33.  
  34. function hash($text) {
  35. return sha1(md5($text).'as5d1sgf5@#%');
  36. }
  37.  
  38. function check_login() {
  39. if(!$_SESSION['logged']) {
  40. return true;
  41. }else{
  42. return false;
  43. }
  44. }
  45.  
  46. function get_user_data($user_id) {
  47.  
  48. if($user_id == NULL) {
  49. $user_id = $_SESSION['user_id'];
  50. }
  51.  
  52. $result = mysql_query("SELECT * FROM `users` WHERE `name` = '{$user_id}' LIMIT 1");
  53. if(mysql_num_rows($result) == 0) {
  54. return false;
  55. }
  56. return mysql_fetch_assoc($result);
  57. }
  58.  
  59. function get_rank_data($user_id) {
  60.  
  61. if($user_id == NULL) {
  62. $user_id = $_SESSION['user_id'];
  63. }
  64.  
  65. $user_data = get_user_data($user_id );
  66. $rank_id = $user_data['rank']
  67.  
  68. $result = mysql_query("SELECT * FROM `rank` WHERE `name` = '{$rank_id}' LIMIT 1");
  69.  
  70. if(mysql_num_rows($result) == 0) {
  71. return false;
  72. }
  73.  
  74. return mysql_fetch_assoc($result);
  75.  
  76. }
  77.  
  78. function get_anime_data($anime_id) {
  79.  
  80. if($anime_id){
  81.  
  82. if(is_numeric($anime_id)){
  83.  
  84.  
  85. $result = mysql_query("SELECT * FROM `anime` WHERE `id` = '{$anime_id}' LIMIT 1");
  86.  
  87. if(mysql_num_rows($result) == 0) {
  88. return false;
  89. }
  90.  
  91. return mysql_fetch_assoc($result);
  92.  
  93. }
  94.  
  95. if(is_string($anime_id)){
  96. $result = mysql_query("SELECT * FROM `anime` WHERE `name` = '{$anime_id}' LIMIT 1");
  97.  
  98. if(mysql_num_rows($result) == 0) {
  99. return false;
  100. }
  101.  
  102. return mysql_fetch_assoc($result);
  103. }
  104.  
  105. }else{
  106. return false;
  107. }
  108. }
  109.  
  110. function check_perm($how_many) {
  111.  
  112.  
  113. if(check_login()){
  114.  
  115. $rank = get_rank_data($_SESSION['user_id']);
  116. $rank = $rank['perm'];
  117.  
  118. }else{
  119.  
  120. return 0;
  121.  
  122. }
  123.  
  124. if($how_many != NULL){
  125.  
  126. return $rank;
  127.  
  128. }else{
  129.  
  130. if($rank >;= $how_many){
  131.  
  132. return true;
  133.  
  134. }else{
  135. return false;
  136. }
  137.  
  138. }
  139. }
  140.  
  141. function top($from, $how_many, $by){
  142.  
  143. if($from == NULL && $how_many == NULL && $by == NULL){
  144. return false;
  145. }
  146.  
  147. mysql_query("select * from '{$from}' order by '{$by}'");
  148. $result = mysql_query("SELECT * FROM '{$from}' LIMIT '{$how_many}' ");
  149. return mysql_fetch_assoc($result);
  150. }
  151.  
  152. function find_anime($anime_category[1], $anime_category[2], $anime_category[3]) {
  153.  
  154. $result = mysql_query('
  155. SELECT `id` FROM `anime` WHERE
  156. `category_a` = '{$anime_category[1]}'
  157. OR
  158. `category_b` = '{$anime_category[1]}'
  159. OR
  160. `category_c` = '{$anime_category[1]}'
  161. OR
  162. `category_a` = '{$anime_category[2]}'
  163. OR
  164. `category_b` = '{$anime_category[2]}'
  165. OR
  166. `category_c` = '{$anime_category[2]}'
  167. OR
  168. `category_a` = '{$anime_category[3]}'
  169. OR
  170. `category_b` = '{$anime_category[3]}'
  171. OR
  172. `category_c` = '{$anime_category[3]}'
  173. ');
  174.  
  175. return mysql_fetch_assoc($result);
  176. }
  177.  
  178. function summation(){
  179.  
  180. }
  181.  
  182.  
  183. if(!isset($_SESSION['logged'])) {
  184. $_SESSION['logged'] = false;
  185. $_SESSION['user_id'] = -1;
  186. }
  187.  
  188. ?>


...i bardzo krótki "index.php":

  1. <?
  2. define('include_perm', TRUE);
  3. include 'core.php';
  4. db_connect();
  5. ?>
  6.  
  7. <link rel="Stylesheet" type="text/css" href="style.css" />
  8.  
  9. <title>AnimePlay</title>
  10.  
  11. <body>
  12. fghdgfhdfghdfgh
  13. <div styles="background-color: black">
  14. cghjdghjghjfgjhfghjfgjhfghj
  15. </div>
  16.  
  17. </body>


Problem mój wygląda następująco: ten tekst w divie i poza diviem, nie wyświetla się. Tekst jeżeli jest przed include to jest widoczny, jeżeli zaś na początku "core.php" to już nie widoczny snitch.gif próbowałem session_start() bo niektórzy na forach, pisali, że im to "znika" strony, ale jednak nie.

To czego to jest przyczyna? Pomóżcie. Z góry dzięki.
Go to the top of the page
+Quote Post
Tajgeer
post 1.06.2012, 21:58:35
Post #2





Grupa: Zarejestrowani
Postów: 290
Pomógł: 48
Dołączył: 11.05.2008
Skąd: Kielce

Ostrzeżenie: (0%)
-----


  1. ini_set('display_errors', 1);
Go to the top of the page
+Quote Post
Maxie
post 1.06.2012, 22:09:12
Post #3





Grupa: Zarejestrowani
Postów: 82
Pomógł: 1
Dołączył: 19.10.2011

Ostrzeżenie: (0%)
-----


Dziękuję, dzięki temu pokazało mi kilka razy błąd i go poprawiłem. Temat do zamknięcia.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 2.07.2025 - 22:32