is not a valid MySQL result resource

asterisk*2a

Mitglied
index.php
PHP:
<?php	//*****************************
	//****   NEWS SITE INDEX   ****
	//*****************************
	
	$rootdir="../";
	$section="news";
	//$setlocale("LC_ALL", german);
	// Layout laden #1
	include("../layout/include/header.inc.php");			


	//Kontakt zu Datenbank
	$db = mysql_connect ("localhost","asterisk-2a","q3a") or die ("Verbindung fehlgeschlagen");
	
		mysql_select_db ("team-ashlen",$db);
		$news_SQL = "SELECT * FROM news ORDER BY news_datetime DESC";
		$news_result = mysql_query ($news_SQL);
	
	
    //Ausgabe NEWS
    while ($news = mysql_fetch_array($news_result)) {
	
	//Formatierung des Datums
	$ts=$news['news_datetime'];
	$unixtime = mktime(substr($ts,11,12),substr($ts,14,15),substr($ts,17,18),substr($ts,5,6),substr($ts,8,9),substr($ts,0,4));

	//Konvertiere Zeilenumbrüche in HTML-<br>-Umbrüche
  	//$news['news_main'] = nl2br($news['news_main']);
  	
	//Kürzen der News und :: read more Link
	if (strlen ($news['news_main']) > 220) {
		$news['news_main'] = substr($news['news_main'],0,180) 
		." [...]";
		$morelink = "<a href=../news/news.php?news_ID=" .$news['news_ID'].">";
	}

	$nowid = $news['news_ID'];
	echo $nowid;
	
	
?> 

<br>
<table width="420" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="420" height="40" valign="top"> 
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="50" valign="top" rowspan="2"> 
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr> 
                <td width="50" height="40"><img src="file:///E|/www2/layout/bilder/news_misc_pc.jpg" width="30" height="30"></td>
              </tr>
            </table>
          </td>
          <td width="1" height="31" valign="top"> 
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr> 
                <td width="1" height="31"></td>
              </tr>
            </table>
          </td>
          <td width="369" valign="top" align="left"><b><font face="Arial, Helvetica, sans-serif" size="2"><?php echo $news['news_head'] ?></font></b> 
          <br>
          <font face="Arial, Helvetica, sans-serif" size="1"><b><?php echo $news['news_author'] ?></b> am <?php echo date("l, \\d\e\\n  d.m.Y \\u\m H:i",$unixtime) ?></font></td>
        </tr>
        <tr> 
          <td height="9"></td>
          <td></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr> 
    <td valign="top" height="60"> 
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="420" height="60" valign="top"><font face="Arial, Helvetica, sans-serif" size="2"><?php echo $news['news_main'] ?></font></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr> 
    <td height="35" valign="top"> 
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td height="35" width="420" valign="top" align="right"><font face="Arial, Helvetica, sans-serif" size="2">
          <b>:: <?php echo $morelink ?> read more</a></b>
          <br>
          	<?php
          	$ncom_SQL = "SELECT * FROM news-comments WHERE news_ID = '$nowid'";
		$ncom_result = mysql_query($ncom_SQL);
		$ncom_rows = mysql_num_rows($ncom_result);
		
		echo "( ".$ncom_rows." Comments )";
          	?>
          </font></td>
        </tr>
      </table>
    </td>
  </tr>
</table>


<?php

	//While-Schleife ZU
	}
		
		//Datenbankverbindung ZU
		mysql_close();


	// Layout laden #2
	include("../layout/include/footer.inc.php");


?>


Ich bekomme folgende Fehlermeldung:
Warning: Supplied argument is not a valid MySQL result resource in e:\www2\news\index.php on line 93

nach ::read more und die ( Comments ) wird angezeigt!!!

Zeile 93 ist die hier:
$ncom_rows = mysql_num_rows($ncom_result);

Apache 1.3
MySQL 3.23.38
PHP 4.06
Win2000 SP2

In der SQL Datenbank sind folgende einträge:
news:
news_ID
news_logo
" _head
" _author
" _datetime
" _main
" _links
" _show

news-comments:
news_ID
comment_name
comment_text
" _datetime

- - - - - - - - - - - - - - - - - - - - - -

Das ganze soll halt ein NewsScript sein was einen gekürzten Text hat (um vollen text zu lesen muss auf read more geklickt werden). und was die Gast Kommentare (auch Comments genannt) anzeigt !

Bloss der will dei Anzahl der bereits vorhandenen Kommentare nicht auslesen (da stehen schon 5 Kommentare drin in der db)

THX für ne Idee was da falsch sein könnte.
PS. Dies is das 3te forum ... seit einer Woche was ich zu rate ziehe.
 
Wiso steht nirgendwo das man bei einem zweiten tabel aufrug den tabel namen in aktzentzeichen setzen muss. ! wtf !
Wie ich drauf gekommen bin ? Ich habs mal so ausprobiert wie der phpMyAdmin das macht.

PHP:
<?php
	//*****************************
	//****   NEWS SITE INDEX   ****
	//*****************************
	
	$rootdir="../";
	$section="news";
	setlocale("LC_ALL","de_DE");
	// Layout laden #1
	include("../layout/include/header.inc.php");			


	//Kontakt zu Datenbank
	$db = mysql_connect ("localhost","asterisk-2a","q3a") or die ("Verbindung fehlgeschlagen");
	
		mysql_select_db ("team-ashlen",$db);
		$news_SQL = "SELECT * FROM news ORDER BY news_datetime DESC";
		$news_result = mysql_query ($news_SQL);
	
	
    //Ausgabe NEWS
    while ($news = mysql_fetch_array($news_result)) {
	
	//Formatierung des Datums
	$ts=$news['news_datetime'];
	$unixtime = mktime(substr($ts,11,12),substr($ts,14,15),substr($ts,17,18),substr($ts,5,6),substr($ts,8,9),substr($ts,0,4));

	//Konvertiere Zeilenumbrüche in HTML-<br>-Umbrüche
  	//$news['news_main'] = nl2br($news['news_main']);
  	
	//Kürzen der News und :: read more Link
	if (strlen ($news['news_main']) > 220) {
		$news['news_main'] = substr($news['news_main'],0,180) 
		." [...]";
		$morelink = "<a href=../news/news.php?news_ID=" .$news['news_ID'].">";
	}
	
	//Aktuelle NewsID zuweisen für CommentAnzahl auslesen
	$nowid = $news['news_ID'];
	
	
?> 

<br>
<table width="420" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td width="420" height="40" valign="top"> 
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="50" valign="top" rowspan="2"> 
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr> 
                <td width="50" height="40"><img src="file:///E|/www2/layout/bilder/news_misc_pc.jpg" width="30" height="30"></td>
              </tr>
            </table>
          </td>
          <td width="1" height="31" valign="top"> 
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
              <tr> 
                <td width="1" height="31"></td>
              </tr>
            </table>
          </td>
          <td width="369" valign="top" align="left"><b><font face="Arial, Helvetica, sans-serif" size="2"><?php echo $news['news_head'] ?></font></b> 
          <br>
          <font face="Arial, Helvetica, sans-serif" size="1"><b><?php echo $news['news_author'] ?></b> am <?php echo date("l, \\d\e\\n  d.m.Y \\u\m H:i",$unixtime) ?></font></td>
        </tr>
        <tr> 
          <td height="9"></td>
          <td></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr> 
    <td valign="top" height="60"> 
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="420" height="60" valign="top"><font face="Arial, Helvetica, sans-serif" size="2"><?php echo $news['news_main'] ?></font></td>
        </tr>
      </table>
    </td>
  </tr>
  <tr> 
    <td height="35" valign="top"> 
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td height="35" width="420" valign="top" align="right"><font face="Arial, Helvetica, sans-serif" size="2">
          <b>:: <?php echo $morelink ?> read more</a></b></font>
          <br><font face="Arial, Helvetica, sans-serif" size="1">
          	
          	<?php
          	$ncom_SQL = "SELECT * FROM `news-comments` WHERE news_ID=$nowid";
		$ncom_result = mysql_query($ncom_SQL);
		$ncom_rows = mysql_num_rows($ncom_result);
		
			if ($ncom_rows == 0) {
				//Nichts Anzeigen
			} else {
				echo "( ".$ncom_rows." Comments )";
			}
          	?>
          	
          </font></td>
        </tr>
      </table>
    </td>
  </tr>
</table>


<?php

	//While-Schleife ZU
	}
		
		//Datenbankverbindung ZU
		mysql_close();


	// Layout laden #2
	include("../layout/include/footer.inc.php");


?>

So und nur deswegen Tag um Tag verplempert. Und Onlinekosten hochgeschraupt.
 
Zurück