Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] Nie działają funkcje MySQL
dzobert
post 4.07.2006, 19:39:11
Post #1





Grupa: Zarejestrowani
Postów: 46
Pomógł: 1
Dołączył: 30.06.2006
Skąd: okolice Warszawy

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


zainstalowałem sobie ostatnio apacha 2.0.58, mysqla 5.0.22 i php 5.1.4. Wszystko działa, lecz php nie wykonuje zapytań mysql'a np. mysql_connect. Mogłem coś źle skonfigurować jeśli tak to powiedzcie co, albo może to być błąd w skrypcie

  1. <?php
  2.  header('Content-Type: text/html; charset = iso-8859-2');
  3.  if (!$dbconnect = mysql_connect('localhost', 'root', 'nie podam')) {
  4. echo "Nie można się połączyć z 'localhost'.";
  5.  } // if
  6.  if (!mysql_select_db('news_xml')) {
  7. echo "Nie można się połączyć z bazą 'news_xml'";
  8.  } // if
  9.  $table_id = 'item';
  10.  $dbresult = mysql_query("SELECT * FROM $table_id");
  11.  // Utworz nowy dokument DOM
  12.  $dom = new DOMDocument('1.0', 'iso-8859-2');
  13.  
  14.  // create the root element
  15.  $rss = $dom->createElement('rss');
  16.  $dom->appendChild($rss);
  17.  $newattr = $dom->createAttribute('version');
  18.  $rss->appendChild($newattr);a
  19.  $sattr = $rss->setAttribute('version', '2.0');
  20.  $rss->appendChild($sattr); 
  21.  
  22.  // create the channel element
  23.  $channel = $dom->createElement('channel');
  24.  $rss->appendChild($channel);
  25.  
  26.  // now create all the subelements for the channel
  27.  $title = $channel->appendChild($dom->createElement('title'));
  28.  $title->appendChild($dom->createTextNode('4asy'));
  29.  
  30.  $link = $channel->appendChild($dom->createElement('link'));
  31.  $link->appendChild($dom->createTextNode('http://www.czteryasy.pl'));
  32.  
  33.  $description = $channel->appendChild($dom->createElement('description'));
  34.  $description->appendChild($dom->createTextNode('Wydarzenia w naszej firmie'));
  35.  
  36.  $language = $channel->appendChild($dom->createElement('language'));
  37.  $language->appendChild($dom->createTextNode('pl'));
  38.  
  39.  $webMaster = $channel->appendChild($dom->createElement('webMaster'));
  40.  $webMaster->appendChild($dom->createTextNode('Dzobert@interia.pl')); 
  41.  
  42.  // create the image element
  43.  $image = $channel->appendChild($dom->createElement('image'));
  44.  $image->appendChild($dom->createTextNode(''));
  45.  
  46.  // now create all the subelements for the image
  47.  $title = $image->appendChild($dom->createElement('title'));
  48.  $title->appendChild($dom->createTextNode('4asy'));
  49.  
  50.  $link = $image->appendChild($dom->createElement('link'));
  51.  $link->appendChild($dom->createTextNode('http://www.czteryasy.pl/'));
  52.  
  53.  $url = $image->appendChild($dom->createElement('url'));
  54.  $url->appendChild($dom->createTextNode('http://www.czteryasy.pl/style/img/nav.gif'));
  55.  
  56.  $height = $image->appendChild($dom->createElement('height'));
  57.  $height->appendChild($dom->createTextNode('80'));
  58.  
  59.  $width = $image->appendChild($dom->createElement('width'));
  60.  $width->appendChild($dom->createTextNode('80'));
  61.  // zaďż˝aduj wiersz z bazy
  62.  while ($row = mysql_fetch_assoc($dbresult)) {
  63.  // utwórz element/wezel dla kazdego rekordu
  64. $occ = $dom->createElement($table_id);
  65. $channel->appendChild($occ);
  66. // Dodaj węzeł potomny dla każďego z elementďów
  67. foreach ($row as $fieldname => $fieldvalue) {($occ);
  68. $child = $dom->createElement($fieldname);
  69.  $occ->appendChild($child);
  70.  $value = $dom->createTextNode($fieldvalue);
  71.  $child->appendChild($value);
  72. } // foreach
  73.  } // while
  74. // pobierz gotowy dokument XML
  75.  $xml_result = $dom->saveXML();
  76.  print $dom->save("rss.xml");
  77.  
  78. print <<<XML_SHOW
  79. <textarea cols='150' rows='40' name='xml_result'>$xml_result</textarea>
  80. XML_SHOW;
  81. ?>


Może to być błąd w pliku php.ini?
Go to the top of the page
+Quote Post

Posty w temacie


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: 14.08.2025 - 11:41