Jump to content


news error


6 replies to this topic

#1 venomsnake

    Jedi In Training

  • Members
  • PipPip
  • 481 posts
  • Gender:Male

Posted 09 November 2005 - 07:55 PM

ive had this error before and i fixed it before, but something is really wrong, on http://gamingreloaded.com/ i get the error that it shows, i tried changing the template to show the news, i even tried changing databases, and nothing fixes it, and the database is not empty.

the news system just stopped working, i have an anther set of files of this system for someone else and it works fine, i tried taking those files and using them but it doesnt work.

heres the file code:
<?php
include 'dbconnect.php';
$result = mysql_query("select * from news order by id desc limit 10");
while($r=mysql_fetch_array($result))
{
$id=$r["id"];
$title=$r["title"];
$newstext=$r["newstext"];
$date=$r["date"];
$icon=$r["icon"];
$username=$r["name"];
$news = nl2br("$newstext");
$count = mysql_query("SELECT * FROM `comments` WHERE commentid = '$id'");
$comments = mysql_num_rows($count);
  echo "<table width='408px' border='0' cellspacing='0'>
                <tr>
              <td style='border-bottom: 1px dotted #CFCFCF'><b>$title</b><br>
    Reported by: $username on $date</td>
              </tr>
              <tr>
              <td style='border-bottom: 1px dotted #CFCFCF'>$news</td>
              </tr>
              <tr>
              <td style='text-align: right'><a href=\"news.php?id=$id\">$comments Comments</a></div> </td>
              </tr>
              </table>
              <br>";
}
?>


#2 MillerTime

    Young Padawan

  • Members
  • Pip
  • 69 posts

Posted 09 November 2005 - 10:49 PM

<?php
include 'dbconnect.php';
$result = mysql_query("select * from news order by id desc limit 10") or die("1. "mysql_error());
while($r=mysql_fetch_array($result))
{
$id=$r["id"];
$title=$r["title"];
$newstext=$r["newstext"];
$date=$r["date"];
$icon=$r["icon"];
$username=$r["name"];
$news = nl2br("$newstext");
$count = mysql_query("SELECT * FROM `comments` WHERE commentid = '$id'") or die("2. "mysql_error());
$comments = mysql_num_rows($count);
 echo "<table width='408px' border='0' cellspacing='0'>
               <tr>
             <td style='border-bottom: 1px dotted #CFCFCF'><b>$title</b><br>
   Reported by: $username on $date</td>
             </tr>
             <tr>
             <td style='border-bottom: 1px dotted #CFCFCF'>$news</td>
             </tr>
             <tr>
             <td style='text-align: right'><a href=\"news.php?id=$id\">$comments Comments</a></div> </td>
             </tr>
             </table>
             <br>";
}
?>

try that. Get use to using mysql_error()

#3 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 10 November 2005 - 12:23 AM

Well, i don't know what's with the 1, but you put your dot in the wrong spot.
$result = mysql_query("select * from news order by id desc limit 10") or die(mysql_error());
So i removed the string all together.

#4 saferwaters

    Jedi In Training

  • Members
  • PipPip
  • 390 posts

Posted 10 November 2005 - 09:13 AM

Cant you only access mysql_fetch_array results through variables with numbers in teh square braces? Im still learning PHP mind you...

So the results would be like
$id=$r[0];
$title=$r[1];
$newstext=$r[2];
$date=$r[3];
etc etc

#5 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 10 November 2005 - 12:34 PM

You can, but it's easier for the person working with the script to use names instead.

#6 venomsnake

    Jedi In Training

  • Members
  • PipPip
  • 481 posts
  • Gender:Male

Posted 11 November 2005 - 06:12 PM

now its saying

Table 'cory_grcontent.news' doesn't exist

even tho in the dbconnect file, the table is cory_grnews

#7 venomsnake

    Jedi In Training

  • Members
  • PipPip
  • 481 posts
  • Gender:Male

Posted 12 November 2005 - 07:10 PM

can anyone please help me? i need to get it fixed





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users