Mam dwa pliki: content.php (który zawiera js) i display_gorace_oferty.php.

część kodu content.php

  1. <script type="text/javascript">
  2.  
  3. /*Example message arrays for the two demo scrollers*/
  4.  
  5. var pausecontent=new Array()
  6. <?php include "display_gorace_oferty.php"; ?>
  7. /*pausecontent[0]='<a href="http://www.javascriptkit.com">JavaScript Kit</a><br />Comprehensive JavaScript tutorials and over 400+ free scripts!'
  8. pausecontent[1]='<a href="http://www.codingforums.com">Coding Forums</a><br />Web coding and development forums.'
  9. pausecontent[2]='<a href="http://www.cssdrive.com" target="_new">CSS Drive</a><br />Categorized CSS gallery and examples.'
  10. */
  11. </script>


kod display_gorace_oferty.php
  1. <?php
  2. error_reporting(E_ALL ^ NOTICE);
  3. ?>
  4. <!DOCTYPE html
  5. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
  6. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  7. <html xmlns="http://www.w3.org/1999/xhtml">
  8. <head>
  9. <title>Główna</title>
  10. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  11. <link rel="stylesheet" type="text/css" href="style.css" />
  12. </head>
  13. <body>
  14. <?php
  15. include "admin/globals.php";
  16. $connection = mysql_connect(DB_HOST, DB_USER, DB_PASSWD) or die ("Błąd");
  17. mysql_select_db(DB_NAME, $connection);
  18. $query = mysql_query("SELECT * FROM GoraceOferty");
  19. $i=0;
  20. while ($row = mysql_fetch_array($query)) {
  21. $row['tresc_GoraceOferty'] = nl2br($row['tresc_GoraceOferty']);
  22. $row['tresc_GoraceOferty'] = str_replace("r","",$row['tresc_GoraceOferty']);
  23. $row['tresc_GoraceOferty'] = str_replace("\n","",$row['tresc_GoraceOferty']);
  24. echo "pausecontent[".$i."]='".$row['tresc_GoraceOferty']."'\nr";
  25. $i++;
  26. }
  27. ?>
  28. </body></html>


Link: http://poligrafia1.nazwa.pl/helmut/orbis2
Link 2: http://poligrafia1.nazwa.pl/helmut/orbis

Dlaczego w pierwotnej wersji (link 2) skrypt działa, a w drugiej (link) nie działa?
Przypuszczam, że jest to wina złego includowania pliku php w znaczniku <script type="text/javascript">...</script>
Ale dlaczego w takim razie w pierwotnej wersji działa?