Autor Beitrag
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Fr 02.02.07 17:01 
Hui, so viele Schlüsselwörter sollten gar nicht in den Titel...

Jedenfalls: auch ich bin jetzt ein Blogger. Und da hab ich mir gedacht, die News meiner Seite lasse ich auch über Wordpress laufen. Dann noch en DB-Query nach der entsprechenden Kategorie ('Intern',6) fertig. Funktioniert auch fast.

Nur mit Umlauten gibt es ein Problem.
Am besten ihr guckt euch das mal Live an:

meine Query: martok.kilu.de/index.php
Wordpress: martok.kilu.de/blog/?cat=6
(der Blog-Titel ist erstmal noch vorläufig, der Inhalt stammt noch von der Vorversion mit statischem HTML.)

Man sieht sehr schön: da passt was nicht. Wenn ich die Query über phphMyAdmin absetze, gibts den gleichen Zeichensalat. Was kann man da machen? Die Collation der Felder ist latin_swedish_ci, sollte doch also gehen!?

Achja, der Code ;)

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
<?php
  if ($dbconn = ......) {
    $db = mysql_select_db(.....);
    $query = "SELECT p.`post_content`, p.`post_title`, p.`post_date`
       FROM wp_posts p, wp_post2cat c
       WHERE c.`category_id` = 6
       AND p.`ID` = c.`post_id`
       ORDER BY p.`post_date` DESC
       LIMIT 5";
    if ($res = mysql_query($query)) {
      while ($row=mysql_fetch_array($res)) {
        $pd = $row['post_date'];
        $pt = $row['post_title'];
        $pc = $row['post_content'];
        echo <<<END
            <div class="post">
              <div class="date">$pd</div>
              <div class="title">$pt</div>
              <div class="storycontent">
                $pc
              </div>
            </div>
END;
      }
    }
  }
?>

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Roadrunner116
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 89

Win XP Home, Ubuntu Linux 6.06
Delphi 7, Java, PHP
BeitragVerfasst: Fr 02.02.07 18:55 
Ich weiß zwar nicht, ob das das richtige Forum für eine solche Frage ist, aber ich habe in meinem cms-system das problem gelöst, indem ich eine function.php erstellt habe und diese in das eigentliche script eingebunden habe.

function.php
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
<?php
    function changetext($str)
    {
        $str = trim($str);
        $str = preg_replace('/\S{60}/', '\0 ', $str);
        $str = htmlspecialchars($str);
        $str = preg_replace('/(\s{2})\s+/', '\1', $str);
        $str = nl2br($str);

        return $str;

    }
?>


Gruß Roadrunner116
Martok Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Fr 02.02.07 20:48 
Ich liebe RegEx. Die versteht man immer so schön...
Leider hilft mir dein Code nicht weiter. Diese Komischen Zeichen bleiben bestehen...

Das das hier kein PHP-Forum ist, ist mir auch klar. Nur gibt es hier recht viele kompetente Leute, und da ich mir nicht sicher war, ob es vielleicht doch die DB ist...

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 03.02.07 02:07 
Bei den Zeichensätzen verhaue ich mich immer und muss es dann einfach ausprobieren (typeof(Gedächtnis) = Sieb), aber für mich sieht das aus, als wäre das Zeug UTF8-kodiert. Probiere mal, ein utf8_decode auf den Text loszulassen, bevor Du ihn ausgibst.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Martok Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Sa 03.02.07 02:31 
Aha, jetzt weiß ich warum du Chefentwickler bist ;)

:flehan: :flehan: user profile iconChristian S.

Funktioniert. Super, so eine Blog-Software ist schon toll. Jetzt muss die nur noch den NiceName anzeigen, und ich bin zufireden. Naja, mal sehen...

user profile iconChristian S. hat folgendes geschrieben:
(typeof(Gedächtnis) = Sieb)

(typeof(Gedächtnis) == Sieb)
Dürfte eher funktionieren...

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 03.02.07 02:40 
user profile iconMartok hat folgendes geschrieben:
Aha, jetzt weiß ich warum du Chefentwickler bist ;)

:flehan: :flehan: user profile iconChristian S.
Bei so einer Rückmeldung hilft man doch gerne :-)

user profile iconMartok hat folgendes geschrieben:
user profile iconChristian S. hat folgendes geschrieben:
(typeof(Gedächtnis) = Sieb)

(typeof(Gedächtnis) == Sieb)
Dürfte eher funktionieren...
Pffff, das ist Chrome-Quelltext, da hat der Vergleich ein "=", wie sich das gehört :zwinker:

So, Zeit fürs Bett ;-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Roadrunner116
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 89

Win XP Home, Ubuntu Linux 6.06
Delphi 7, Java, PHP
BeitragVerfasst: So 04.02.07 13:32 
sorry, da smit dem "ich weiß nicht ob das das richtige forum ist" war kein meckern sondern ein echtes überegen, da ich es wirklichnicht weiß...
So
zu meinem code!
dieses changetext musst du bei dem speichenr in die Datenbank eingeben, weil die datenbank kein Ä,Ö,Ü,ß,... speichert, du also beim laden nix ersetzen kannst!
FUnktioniert bei mir zu mindest einwandfrei, wenn du es direkt mit den "html-zeichen" (&auml;) speicherst und dafür ist der quellcode gut!
Hätte vielleicht sagen können wo der eingefügt werden muss... sorry ;-)


Gruß Roadrunner116
Martok Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: So 04.02.07 14:20 
Das das kein Meckern war ist schon klar.
Beim Speichern zu ersetzen ist an sich eine gute Idee. Das Problem ist nur: der Wordpress Code ist so undurchsichtig, das finde ich nie :) außerdem wird bei der Ausgabe schon escaped, was dann doppelt werden würde.

Irgendwie scheint es jetzt ja aber mit utf8_decode zu gehen. Also irgendwas in der Richtung muss ja wohl doch in der DB stehen..

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."