WinFuture-Forum.de: Php Code-frage - WinFuture-Forum.de

Zum Inhalt wechseln

Nachrichten zum Thema: Entwicklung
Seite 1 von 1

Php Code-frage


#1 Mitglied ist offline   Lein@d 

  • Gruppe: aktive Mitglieder
  • Beiträge: 131
  • Beigetreten: 20. März 05
  • Reputation: 0

geschrieben 17. Februar 2006 - 22:52

Ich benutze ein PHPNewsscript von "PHPNews" es funktioniert alles nur das Archiv nicht.
(Ich muss ehrlich sagen mit HTML kenn cih mich recht gut aus aber PHP ist fast alles neu für mich.)

So steht es in der Readme:

Including the Archives

PHPNews automatically sorts all news into Archives. You can display your Archives 1 of 2 different ways. You can either order your News by Month and Year, or by The Catgeory it was added to (News Categories are an optional feature which can be enabled in your Settings). Including your Archives is done just like your News (You cannot display your News and Archives on the same page)
PHP Code:
<?php
include("path/to/phpnews/archive.php");
?>

Now, you need to place the following piece of PHP code where you want the Archives displayed. To display Archives sorted by Month And Year (default) use this code:
PHP Code:
<?php
byMonth();
?>

To display your Archives sorted by News Categories use the following piece of Code:
PHP Code:
<?php
byCat();
?>




Ich möchte nach Kategorien sortieren also muss ich ja

<?php
byCat();
?>

einfügen.

Was kommt da in die Klammer?

Wenn ich die leer lasse kommt immer folgende Meldung:

Fatal error: Call to undefined function: bycat() in /homepages/1/d39883919/htdocs/cold-as-ice/vonderheide/newsarchiv.php on line 10

Ist bestimmt ganz simpel doch wie gesagt kenn ich mich mit PHP noch nicht so aus.

Dieser Beitrag wurde von Lein@d bearbeitet: 18. Februar 2006 - 00:13

0

Anzeige



#2 Mitglied ist offline   tobiasndw 

  • Gruppe: aktive Mitglieder
  • Beiträge: 3.815
  • Beigetreten: 24. September 03
  • Reputation: 0
  • Geschlecht:Männlich

geschrieben 17. Februar 2006 - 23:03

Wäre ja mal interessant zu erfahren was in der archive.php so drin steht
0

#3 Mitglied ist offline   Lein@d 

  • Gruppe: aktive Mitglieder
  • Beiträge: 131
  • Beigetreten: 20. März 05
  • Reputation: 0

geschrieben 17. Februar 2006 - 23:09

Viel Sehr viel:

<?php
error_reporting (E_ALL ^ E_NOTICE);
/*********************************************
* --------------- *
* | Archive.php | *
* --------------- *
* PHPNews - 1.3.0 Release *
* Open Source Project started by Pierce Ward *
* *
* Software Distributed at: *
* http://newsphp.sourceforge.net *
* ========================================== *
* © 2003, 2005 Pierce Ward (Big P) *
* All rights reserved. *
* ========================================== *
* This program has been written under the *
* terms of the GNU General Public Licence as *
* published by the Free Software Foundation. *
* *
* The GNU GPL can be found in gpl.txt *
*********************************************/

/* Get the absolute path */
$path = __FILE__;
$path = str_replace('archive.php', '', $path);

include($path . 'settings.php');

/* Don't edit - Connects to DB */
$dbcon = mysql_connect($db_server, $db_user, $db_passwd);
mysql_select_db($db_name);

/* Grabs Settings and puts it in an Array */
$result = mysql_query('SELECT variable,value FROM ' . $db_prefix . 'settings');
$dbQueries++;

$Settings = array();
while ($row = mysql_fetch_array($result))
{
$Settings[$row[0]] = $row[1];
}

/* Include The Language File */
$lang = $Settings['language'];

if(!file_exists($path . 'languages/' . $lang . '.news.lng'))
{
include_once($path . 'languages/en_GB.news.lng');
setlocale(LC_TIME, $lang);
}
else
{
include_once($path . 'languages/' . $lang . '.news.lng');
setlocale(LC_TIME, $lang);
}
$language = $lng;

/*
Archive Functions
You can call each function by its name, eg.
<? byMonth(); ?>
You can only call either byMonth(); or byCat();
not both in the same page.
*/

/* Display News in Archive by Month/Year */
function byMonth()
{
global $Settings, $language, $path, $_SERVER, $db_prefix;

/* Order the news by Month/Year */
if (!$_GET['month'] && !$_GET['year'])
{
$SQL_query = mysql_query('SELECT DISTINCT month,year FROM ' . $db_prefix . 'news ORDER by id DESC');

while ($arc = mysql_fetch_assoc($SQL_query))
{
/* Get the total number of posts per month */
$total = mysql_query('SELECT count(*) as total FROM ' . $db_prefix . 'news WHERE month = \'' . $arc['month'] . '\' AND year = \'' . $arc['year'] . '\'');
$var = mysql_fetch_assoc($total);

/* Set up Variables for Template */
$month = strftime('%B', mktime(0, 0, 0, $arc['month'], 1, 0));
$year = $arc['year'];
$numPosts = $var['total'];
$url = $_SERVER['PHP_SELF'];

include($path . 'templates/date_temp.php');
}
}
/* Display links to the articles */
else if (isset($_GET['month']) && isset($_GET['year']))
{
$SQL_query = mysql_query('SELECT n.id,n.posterid,n.postername,n.subject,n.time,p.us
ername,p.email'
. ' FROM ' . $db_prefix . 'news AS n'
. ' LEFT JOIN ' . $db_prefix . 'posters AS p ON(n.posterid=p.id)'
. ' WHERE month=\'' . $_GET['month']. '\' AND year=\'' . $_GET['year'] . '\''
. ' AND n.trusted = 1'
. ' ORDER by n.id DESC');

while ($posts = mysql_fetch_assoc($SQL_query))
{
/* Set up easy variables */
$url = $Settings['siteurl'];
$id = $posts['id'];
$subject = stripslashes($posts['subject']);
$username = $posts['username'];
$time = strftime($Settings['shorttimeformat'], $posts['time']);

if (!$username)
{
$username = $posts['postername'];
}

if ($posts['email'] != '')
{
$username = '<a href="mailto:' . $posts['email'] . '">' . $username . '</a>';
}
else
{
$username = $username;
}

include($path . 'templates/link_temp.php');
}
}
/* Otherwise, something went wrong, so print out an error message */
else
{
echo '<b>' , $language['CONTENT_ERROR'] , '</b>: ' , $language['CONTENT_ERRORREQUIREDVARIABLE'];
}
}

/* Display News in Archive ordered by Categories */
function byCat()
{
global $Settings, $language, $path, $_SERVER, $db_prefix;

/* Sort News by Categories */
if (!$_GET['cat'])
{
$SQL_query = mysql_query('SELECT DISTINCT * FROM ' . $db_prefix . 'categories ORDER by id ASC');
while ($cat = mysql_fetch_assoc($SQL_query))
{
$url = $_SERVER['PHP_SELF'];
$catid = $cat['id'];
$category = $cat['catname'];

if ($cat['caticon'] != '')
{
$caticon = '<img src="' . $cat['caticon'] . '" border="0" alt="' . $category . '">';
}
else
{
$caticon = '';
}

include($path . 'templates/cat_temp.php');
}
}
/* Sort News by month, with News from selected Category only */
else if (isset($_GET['cat']) && !isset($_GET['month']) && !isset($_GET['year']))
{
$SQL_query = mysql_query('SELECT DISTINCT month,year FROM ' . $db_prefix . 'news ORDER by id DESC');

while ($cat = mysql_fetch_assoc($SQL_query))
{
/* Get the total number of posts per month */
$total = mysql_query('SELECT count(*) as total FROM ' . $db_prefix . 'news WHERE catid = \'' . $_GET['cat'] . '\' AND month=\'' . $cat['month'] . '\' AND year=\'' . $cat['year'] . '\'');
$var = mysql_fetch_assoc($total);

/* Set up easy Variables */
$month = strftime('%B', mktime(0, 0, 0, $cat['month'], 1, 0));
$year = $cat['year'];
$numPosts = $var['total'];
$url = $_SERVER['PHP_SELF'];
$catid = $_GET['cat'];

include($path . 'templates/catdate_temp.php');
}
}
/* Display the news links from the Category */
else if (isset($_GET['cat']) && isset($_GET['month']) && isset($_GET['year']))
{
$SQL_query = mysql_query('SELECT n.id,n.posterid,n.postername,n.subject,n.time,p.us
ername,p.email'
. ' FROM ' . $db_prefix . 'news AS n'
. ' LEFT JOIN ' . $db_prefix . 'posters AS p ON(n.posterid=p.id)'
. ' WHERE catid=\'' . $_GET['cat'] . '\' AND month=\'' . $_GET['month']. '\' AND year=\'' . $_GET['year'] . '\''
. ' AND n.trusted = 1'
. ' ORDER by n.id DESC');

while ($posts = mysql_fetch_assoc($SQL_query))
{
/* Set up easy variables */
$url = $Settings['siteurl'];
$id = $posts['id'];
$subject = stripslashes($posts['subject']);
$username = $row['username'];
$time = strftime($Settings['shorttimeformat'], $posts['time']);

if (!$username)
{
$username = $posts['postername'];
}

if ($row['email'] != '')
{
$username = '<a href="mailto:' . $row['email'] . '">' . $username . '</a>';
}
else
{
$username = $username;
}

include($path . 'templates/link_temp.php');
}
}
else
{
/* Otherwise, something went wrong, so print out an error message */
echo '<b>' , $language['CONTENT_ERROR'] , '</b>: ' , $language['CONTENT_ERRORREQUIREDVARIABLE'];
}
}
?>
0

#4 Mitglied ist offline   tobiasndw 

  • Gruppe: aktive Mitglieder
  • Beiträge: 3.815
  • Beigetreten: 24. September 03
  • Reputation: 0
  • Geschlecht:Männlich

geschrieben 17. Februar 2006 - 23:22

Und hast du über deinem "byCat()"-Aufruf auch das include stehen?

"include("path/to/phpnews/archive.php");"
0

#5 Mitglied ist offline   Lein@d 

  • Gruppe: aktive Mitglieder
  • Beiträge: 131
  • Beigetreten: 20. März 05
  • Reputation: 0

geschrieben 17. Februar 2006 - 23:30

Beitrag anzeigenZitat (tobiasndw: 17.02.2006, 23:22)

Und hast du über deinem "byCat()"-Aufruf auch das include stehen?

"include("path/to/phpnews/archive.php");"



So sieht es bei mir aus:

<html>
<head>
<title>... von der heide</title>
</head>
<body>
<?php
include("http://www-cold-as-ice.de/vonderheide/phpnews/archive.php");
?>
<?php
byCat();
?>
</body>
</html>
0

#6 Mitglied ist offline   tobiasndw 

  • Gruppe: aktive Mitglieder
  • Beiträge: 3.815
  • Beigetreten: 24. September 03
  • Reputation: 0
  • Geschlecht:Männlich

geschrieben 18. Februar 2006 - 00:01

dann mach mal bitte aus dem "include" ein "require"
0

#7 Mitglied ist offline   Lein@d 

  • Gruppe: aktive Mitglieder
  • Beiträge: 131
  • Beigetreten: 20. März 05
  • Reputation: 0

geschrieben 18. Februar 2006 - 00:06

Beitrag anzeigenZitat (tobiasndw: 18.02.2006, 00:01)

dann mach mal bitte aus dem "include" ein "require"


Dann kommt diese Fehlermeldung:

Fatal error: main(): Failed opening required 'http://www-cold-as-ice.de/vonderheide/phpnews/archive.php' (include_path='.:/usr/local/lib/php') in /homepages/1/d39883919/htdocs/cold-as-ice/vonderheide/newsarchiv.php on line 12
0

#8 Mitglied ist offline   tobiasndw 

  • Gruppe: aktive Mitglieder
  • Beiträge: 3.815
  • Beigetreten: 24. September 03
  • Reputation: 0
  • Geschlecht:Männlich

geschrieben 18. Februar 2006 - 00:07

jo und da du schlau bist schlussfolgerst du daraus das du dich bei deinem include-Pfad verschrieben hast. Du hast nämlich "www-" statt "www." geschrieben.
0

#9 Mitglied ist offline   Lein@d 

  • Gruppe: aktive Mitglieder
  • Beiträge: 131
  • Beigetreten: 20. März 05
  • Reputation: 0

geschrieben 18. Februar 2006 - 00:11

Stimmt das ahbe ich gemerkt!

Wurde geändert.

Es kommt aber immernoch der Fehler:

Fatal error: Call to undefined function: bycat() in /homepages/1/d39883919/htdocs/cold-as-ice/vonderheide/newsarchiv.php on line 10

Dieser Beitrag wurde von Lein@d bearbeitet: 18. Februar 2006 - 00:13

0

#10 Mitglied ist offline   tobiasndw 

  • Gruppe: aktive Mitglieder
  • Beiträge: 3.815
  • Beigetreten: 24. September 03
  • Reputation: 0
  • Geschlecht:Männlich

geschrieben 18. Februar 2006 - 00:13

lass ruhig mal das "require" stehen.

Hast du Groß und Kleinschreibung der Funktion beachtet?
0

#11 Mitglied ist offline   Lein@d 

  • Gruppe: aktive Mitglieder
  • Beiträge: 131
  • Beigetreten: 20. März 05
  • Reputation: 0

geschrieben 18. Februar 2006 - 00:16

Groß und Klein?

Mein code lautet jetzt:

<html>
<head>
<title>... von der heide</title>
</head>
<body>
<?php
require("http://www.cold-as-ice.de/vonderheide/phpnews/archive.php");
?>
<?php
byCat();
?>
</body>
</html>
0

#12 Mitglied ist offline   tobiasndw 

  • Gruppe: aktive Mitglieder
  • Beiträge: 3.815
  • Beigetreten: 24. September 03
  • Reputation: 0
  • Geschlecht:Männlich

geschrieben 18. Februar 2006 - 00:19

ach ich weiß,

du musst den Pfad relativ angeben. Also keine URL mit HTTP

also nur

require("phpnews/archive.php");

Dieser Beitrag wurde von tobiasndw bearbeitet: 18. Februar 2006 - 00:23

0

#13 Mitglied ist offline   Lein@d 

  • Gruppe: aktive Mitglieder
  • Beiträge: 131
  • Beigetreten: 20. März 05
  • Reputation: 0

geschrieben 18. Februar 2006 - 00:22

Ok das geht erst einmal! Vielen Dank!

Kannst du mir auch noch sagen wie ich nur eine Kategorie Auflisten kann?
0

#14 Mitglied ist offline   tobiasndw 

  • Gruppe: aktive Mitglieder
  • Beiträge: 3.815
  • Beigetreten: 24. September 03
  • Reputation: 0
  • Geschlecht:Männlich

geschrieben 18. Februar 2006 - 00:23

Wenns keine fertige Funktion dafür gibt muss es progammiert werden.
0

#15 Mitglied ist offline   Lein@d 

  • Gruppe: aktive Mitglieder
  • Beiträge: 131
  • Beigetreten: 20. März 05
  • Reputation: 0

geschrieben 18. Februar 2006 - 00:26

Ich kann z.B. angeben, dass bei den news nur die Artikel der Kategorie "News" angezeigt werden.

Das muss ich dann so mit in den include Befehl schreiben:

action=showcat&catid=1

Kann cihd as dann nicht irgendwie auch bei dem Newsarchiv machen?

Dieser Beitrag wurde von Lein@d bearbeitet: 18. Februar 2006 - 00:29

0

Thema verteilen:


Seite 1 von 1

1 Besucher lesen dieses Thema
Mitglieder: 0, Gäste: 1, unsichtbare Mitglieder: 0