Using phpNuke for a DB Connection

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Using phpNuke for a DB Connection
_MP_
CZ Newbie
_MP_ has been a member for over 19 year's 19 Year Member
Gender: Male
Status: Offline
Joined: Apr 17, 2005
0.00 posts per day
Posts: 2
Points: 93
   
I have a pretty simple module that im trying to get into nuke. Im having a problem getting connected to the database using phpnuke files. I even have a problem if i try and make a little config file with a database connection and then including it in my scripts.

Whenever i require or include mainfile.php or any other file that refers to mainfile, my module and right blocks disappear. Ive tried using db/db.php and config.php but, it doesn't connect me.

mymodule/admin/test.php
mymodule/admin/delete.php
<?
$id = $_GET["id"];
$name = $_GET["Name"];
$xfire = $_GET["XFire"];
$cmd = $_GET["cmd"];

if(!isset($cmd))
{
$result = "select id, Name, XFire  from xfire";
while($row=mysql_fetch_array($result))
{
$id=$row["id"];
$name=$row["Name"];
$xfire=$row["XFire"];
}
}

if($_GET["cmd"]=="delete")
{
$query = "DELETE FROM xfire WHERE id='$id'";
$sql = @mysql_query($query) or die('Could not delete: '.mysql_error());
echo "$name ID# $id was deleted!";
}
?>


The above script is called by this script by a link. (marked)
mymodule/admin/test.php
<?
include("header.php");
$index=1;

OpenTable();
$cfg = mysql_query("SELECT * from xfirecfg");
while($r=mysql_fetch_array($cfg))
{
   $perpage=$r["Perpage"];
   $style=$r["Style"];
   $size=$r["Size"];
   $sort=$r["Sort"];
   $id=$r["id"];


echo "<form action=modules/XFire2/admin/change.php?cmd=change&id=$id target=_blank method=post>
<table width=98%>
<td align=center valign=top><b>Theme</b>
<select name='Style'>
<option value='$style' ></option>
<option value='bg' >XFire</option>
<option value='os' >Fantasy</option>
<option value='sf' >Sci-Fi</option>
<option value='co' >Combat</option>
</select>
</td>
<td align=center valign=top><b>Size</b>
<select name='Size'>
<option value=$size ></option>
<option value=0 >Classic</option>
<option value=1 >Compact</option>
<option value=2 >Short & Wide</option>
<option value=3 >Tiny</option>
</select>
</td>
<td align=center valign=top><b>Sort</b>
<select name='Sort'>
<option value='$sort' ></option>
<option value='id' >ID</option>
<option value='Name' >Name</option>
<option value='XFire' >XFire</option>
</select><br><br>
</td>
<td align=center valign=top><b>Perpage</b>
<select name='Perpage'>
<option value='$perpage' ></option>
<option value='5' >5</option>
<option value='10' >10</option>
<option value='15' >15</option>
<option value='25' >25</option>
<option value='50' >50</option>
<option value='100' >100</option>
</select>
</td>
<td align=center valign=bottom>
<input type=Submit value=Change>
</td></table>
</form>";
}
CloseTable();


if(!isset($start)) $start = 0;

$query = "SELECT count(*) as count FROM xfire";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];

if($start > 0){
echo "<center>";
echo "<-<a href=\"" . $PHP_SELF . "?op=XFireAdmin&start=" . ($start - $perpage) .
"\">Prev</a>";
echo " - ";
} else {
echo "<center>";
echo "Prev";
echo " - ";
}

if($numrows > ($start + $perpage)){
echo "<a href=\"" . $PHP_SELF . "?op=XFireAdmin&start=" . ($start + $perpage) .
"\">Next</a>->";
echo "</center>";
} else {
echo "Next";
echo "</center>";
}

OpenTable();

$sql = "SELECT id, Name, XFire FROM xfire LIMIT " . $start . ", $perpage";
$result = $db->sql_query($sql);
$num=mysql_numrows($result);

$i=0;
while ($i < $num) {
$Name=mysql_result($result,$i,"Name");
$XFire=mysql_result($result,$i,"XFire");
$id=mysql_result($result,$i,"id");

echo "<form action=modules/XFire2/admin/update.php?cmd=update&id=$id target=_blank method=post>
<table>
<td align=left valign=top>
<b>$id</b>
</td>
<td align=center valign=top>
Name: <input type=text name=Name value=$Name>
</td>
<td align=center valign=top>
XFire: <input type=text name=XFire value=$XFire>
</td>
<td align=center valign=top>
<img src=http://miniprofile.xfire.com/bg/$style/type/$size/$XFire.png border=0>
</td>
<td align=center valign=bottom>
<input type=Submit value=Update><br>

******HERE******
<a href=modules/XFire2/admin/delete.php?cmd=delete&id=$id target=_blank>Delete</a>
******HERE******

</td></table>
</form>";

$i++;
}

CloseTable();

$query = "SELECT count(*) as count FROM xfire";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];

if($start > 0){
echo "<center>";
echo "<-<a href=\"" . $PHP_SELF . "?op=XFireAdmin&start=" . ($start - $perpage) .
"\">Prev</a>";
echo " - ";
} else {
echo "<center>";
echo "Prev";
echo " - ";
}

if($numrows > ($start + $perpage)){
echo "<a href=\"" . $PHP_SELF . "?op=XFireAdmin&start=" . ($start + $perpage) .
"\">Next</a>->";
echo "</center>";
} else {
echo "Next";
echo "</center>";
}

include("footer.php");
?>


All i need, is for a db connect to be established without having to put the actual code on these scripts.

Note: Im also a little new to php/sql


Back to top Reply with quote
#2   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,430
   
How are you calling the module?




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#3   
_MP_
CZ Newbie
_MP_ has been a member for over 19 year's 19 Year Member
Gender: Male
Status: Offline
Joined: Apr 17, 2005
0.00 posts per day
Posts: 2
Points: 93
   
Sorry i don't understand what you mean.



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum