Hi all, can someone take a look at this file and tell me if they can see what im missing. I am very new to working with classes so im sure something is messed up. The problem is this, this code works just fine with the file executed directly (/blahblah.php) if it is not within a class. When I place this file in a class and execute it via a function (/blahblah.somefunction) it will only work (mostly) if I take out $sql .= "order by id DESC LIMIT ".$DPN_row_num.",10"; . I need those in there, the file works just fine outside of the class but not in, so I have a feeling its just something messed up in the code that needs to be changed for a class.. any help is appreciated.
<?php
class oxynews_N_edit
{
function EditNews()
{
commonHeader();
if (!$GLOBALS['g_oSec']->HasSecLvl($GLOBALS['dcl_info']['DCL_DEL_WO']))
return PrintPermissionDenied();
include("oxynews_config.php");
echo"<font face='Verdana, Arial, Helvetica, sans-serif' size='2'>
<center>\n";
if ($id) {
$sql = "SELECT * FROM $oxynews_mysql_table_name WHERE id=$id";
if ($oxynews_usermade) {
$sql .= " and author='".$phpUserLogin_userinfo["short"]."'";
}
$result = mysql_query($sql);
if (@mysql_num_rows($result) > 0) { // If there is news in the table.
$myrow = mysql_fetch_assoc($result);
?>
<a href='class.oxynews_N_edit.inc.php'>Back</a><p>
Edit the fields, and press Update!<br>
Note: Titles can only be 40 characters long.</p>
<form name="form" method="post" action="oxynews_N_edit_process.php">
<input type=hidden name="id" value="<?=$myrow["id"]?>">
<input type=hidden name="DPN_row_num" value="<?=$DPN_row_num?>">
<table>
<tr>
<td colspan="2" align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">Title:</font><br><input type ="text" name = "title" MaxLength=50 value="<?php echo $myrow["title"] ?>"></td>
</tr>
<tr>
<td align="center"><font face="Verdana, Arial, Helvetica, sans-serif" size="1">News:<br><textarea name ="desc" rows = "10" cols = "50" wrap="VIRTUAL"><?php echo $myrow["description"] ?></textarea><br></font>
</td>
</tr>
</table>
<p>
<input type="Submit" name="update" value="Update">
</form>
<?php
} else {
echo "Something went wrong. Press back and try again.\n";
}
} else {
DPN(10,"class.oxynews_N_edit.inc.php",$oxynews_mysql_table_name,$oxynews_usermade);
$sql = "SELECT * FROM $oxynews_mysql_table_name";
if ($oxynews_usermade) {
$sql .= "WHERE author='".$phpUserLogin_userinfo["short"]."' ";
}
$sql .= "order by id DESC LIMIT ".$DPN_row_num.",10";
$result = mysql_query($sql);
$oxynews_num_rows = @mysql_num_rows($result);
$oxynews_i = 0;
if ($oxynews_num_rows > 0) { // If there is news in the table.
echo"Select the title of the news item you wish to edit:<p>";
echo $DPN_Button."<p>";
echo"<table border = '0' width = '65%' align='center'>\n";
while ($rows = mysql_fetch_assoc($result)) {
if (empty($rows[title])) {
$rows[title] = "ERROR - TITLE IS EMPTY";
}
echo" <tr>
<td bgcolor='#CCCCCC'><font face='Verdana, Arial, Helvetica, sans-serif' size='2'><a href=\"?id=$rows[id]&DPN_row_num=$DPN_row_num\"><b>$rows[title]</b></a> - Posted : <b>".$rows[date]." ".$rows[time]." GMT</b> by <b><A HREF='mailto:".$rows[email]."'>".$rows[author]."</A></b></font></td>
</tr>
<tr>
<td bgcolor='#FFFFFF'><font face='Verdana, Arial, Helvetica, sans-serif' size='2'>".oxynews_bbcode($rows[description])."</td>
</tr>\n";
$oxynews_i++;
if ($oxynews_i < $oxynews_num_rows) {
echo" <tr>
<td> </td>
</tr>\n";
}
}
echo"</table><p>";
echo $DPN_Button;
} else {
echo "<font face='Verdana, Arial, Helvetica, sans-serif' size='2'>";
if ($oxynews_usermade) {
echo"No news made by you in the database";
} else {
echo"No news in database";
}
echo"</font>\n";
}
}
echo"</center>
</font>";
}
}
?>