Author |
Message |
bretonmage
Hangin' Around

Joined: Mar 30, 2004
Posts: 34
|
Posted:
Sat Jun 12, 2004 2:48 pm |
|
I've made my own Forms module, the user enters a form which is then sent in email form, and also is inserted into the database (all of that works).
My problem is with the admin area, I cannot get it to work (absolutely NO output within the while() statement, even the simple text). Can anyone take a look at it for me please?
Code:<?php
/*********************************************************************/
/* Squad Forms admin module made by bretonmage (untouchablesite.com) */
/*********************************************************************/
if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
$querystr = "SELECT radminsuper, admlanguage FROM ".$prefix."_authors where aid='$aid'";
$result = sql_query($querystr, $dbi) or die ("invalied query");
list($radminsuper) = sql_fetch_row($result, $dbi);
if ($radminsuper==1) {
include("header.php");
$tablequery = "SELECT radio, sender_name, sender_email, sender_aim, sender_msn, sender_icq, sender_yahoo, message FROM ".$prefix."_squad_forms'";
$resultforms = sql_query($tablequery, $dbi);
while ($resultforms = sql_query($tablequery, $dbi)) {
Opentable();
echo $resultforms['".$prefix."_squad_forms'];
$radio = $row["radio"];
$sender_name = $row["sender_name"];
$sender_email = $row["sender_email"];
$sender_aim = $row["sender_aim"];
$sender_msn = $row["sender_msn"];
$sender_icq = $row["sender_icq"];
$sender_yahoo = $row["sender_yahoo"];
$message = $row["message"];
Closetable();
echo "$sender_name sent an email with the subject of $radio. <br>The message was: <br><br>$message<br><br><a href=\"mailto:$sender_email\">$sender_email</a><br>AIM: $sender_aim<br>MSN: $sender_msn<br>ICQ: $sender_icq<br>Yahoo: $sender_yahoo<br><br>";
};
include("footer.php");
} else {
echo "Access Denied";
}
?>
|
|
|
|
|
 |
Raven
Site Admin/Owner

Joined: Aug 27, 2002
Posts: 17088
|
Posted:
Sat Jun 12, 2004 4:00 pm |
|
Try changing this lineCode:while ($resultforms = sql_query($tablequery, $dbi)) {
| toCode:while ($row = sql_fetch_row($resultforms, $dbi)) {
|
The way you have it wrtitten you are just executing the query and not fetching anything. |
|
|
|
 |
bretonmage

|
Posted:
Sat Jun 12, 2004 4:10 pm |
|
When I do that, I get this error:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home2/untoucha/public_html/includes/sql_layer.php on line 286 |
|
|
|
 |
Raven

|
Posted:
Sat Jun 12, 2004 4:16 pm |
|
That implies that your query => $resultforms = sql_query($tablequery, $dbi); Is not producing anything. |
|
|
|
 |
bretonmage

|
Posted:
Sat Jun 12, 2004 4:33 pm |
|
Hmmm....
I don't quite understand what you mean... But I tried a new script that my friend suggested and it seems to be working; are there any security problems with it?
Code:<?php
/*********************************************************************/
/* Squad Forms admin module made by bretonmage (untouchablesite.com) */
/*********************************************************************/
if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
$querystr = "SELECT radminsuper, admlanguage FROM ".$prefix."_authors where aid='$aid'";
$result = sql_query($querystr, $dbi) or die ("invalied query");
list($radminsuper) = sql_fetch_row($result, $dbi);
if ($radminsuper==1) {
include("header.php");
$dbname = "***";
$dbhost = "***";
$dbuser = "***";
$dbpasswd = "***";
$mysqlservername = $dbname;
$dbcnx = @mysql_connect($dbhost, $dbuser, $dbpasswd);
if (!$dbcnx) {
echo( "<p>Unable to connect to the " . "database server at this time.</p>" );
exit();
}
if (! @mysql_select_db("$mysqlservername") ) {
echo( "<p>Can't find " . "database.</p>" );
exit();
}
$result = @mysql_query("SELECT * FROM nuke_squad_forms");
while ($resultforms = mysql_fetch_array($result)) {
Opentable();
$radio = $resultforms['radio'];
$sender_name = $resultforms['sender_name'];
$sender_email = $resultforms['sender_email'];
$sender_aim = $resultforms['sender_aim'];
$sender_msn = $resultforms['sender_msn'];
$sender_icq = $resultforms['sender_icq'];
$sender_yahoo = $resultforms['sender_yahoo'];
$message = $resultforms['message'];
echo "$sender_name sent an email with the subject of $radio.<br>";
echo "The message was: <br><br>$message<br><br>";
echo "<a href=\"mailto:$sender_email\">$sender_email</a><br>";
echo "AIM: $sender_aim<br>";
echo "MSN: $sender_msn<br>";
echo "ICQ: $sender_icq<br>";
echo "Yahoo: $sender_yahoo<br><br>";
Closetable();
};
include("footer.php");
} else {
echo "Access Denied";
}
?>
|
|
|
|
|
 |
bretonmage

|
Posted:
Sun Jun 13, 2004 4:50 am |
|
Okay, well now my script looks like this:
Code:<?php
/*********************************************************************/
/* Squad Forms admin module made by bretonmage (untouchablesite.com) */
/* Thanks to Tristan for helping me get it working. :-) */
/*********************************************************************/
if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
$querystr = "SELECT radminsuper, admlanguage FROM ".$prefix."_authors where aid='$aid'";
$result = sql_query($querystr, $dbi) or die ("invalied query");
list($radminsuper) = sql_fetch_row($result, $dbi);
if ($radminsuper==1) {
include("header.php");
GraphicAdmin();
$mysqlservername = $dbname;
$dbcnx = @mysql_connect($dbhost, $dbuname, $dbpass);
if (!$dbcnx) {
echo( "<p>Unable to connect to the " . "database server at this time.</p>" );
exit();
}
if (! @mysql_select_db("$mysqlservername") ) {
echo( "<p>Can't find " . "database.</p>" );
exit();
}
$result = @mysql_query("SELECT * FROM nuke_squad_forms");
Opentable();
echo "<center><b><u>Welcome to the Squad Forms administration module. Here you can view forms that have been sent by your members.</b></u></center>";
Closetable();
echo "<br><br>";
while ($resultforms = mysql_fetch_array($result)) {
Opentable();
$radio = $resultforms['radio'];
$sender_name = $resultforms['sender_name'];
$sender_email = $resultforms['sender_email'];
$sender_aim = $resultforms['sender_aim'];
$sender_msn = $resultforms['sender_msn'];
$sender_icq = $resultforms['sender_icq'];
$sender_yahoo = $resultforms['sender_yahoo'];
$message = $resultforms['message'];
echo "'<a href=\"mailto:$sender_email\">$sender_name</a>' sent an email with the subject of '$radio'.<br>";
if ($radio != "Joining" AND $radio != "Rejoining") {
echo "The message was: <br><hr><center><i>$message</i><br><hr></center>";
}
else {
echo "<br>";
};
echo "Email: <a href=\"mailto:$sender_email\">$sender_email</a><br>";
echo "AIM: <a href=\"aim:goim?screenname=$sender_aim&message=Hi+$sender_aim.+Are+you+there?\">$sender_aim</a><br>";
echo "MSN: $sender_msn<br>";
echo "ICQ: $sender_icq<br>";
echo "Yahoo: $sender_yahoo<br>";
Closetable();
echo "<br><br>";
};
include("footer.php");
} else {
echo "Access Denied";
}
?>
|
My question is, how can I make a link that will delete a record from the table? Will I need a new admin page? |
|
|
|
 |
bretonmage

|
Posted:
Sun Jun 13, 2004 7:55 am |
|
Actually, I just got the script to delete records from the table. Unfortunately it deletes ALL records. Here's the script so far:
Code:<?php
/*********************************************************************/
/* Squad Forms admin module made by bretonmage (untouchablesite.com) */
/* Thanks to Tristan for helping me get it working. :-) */
/*********************************************************************/
if (!eregi("admin.php", $_SERVER['PHP_SELF'])) { die ("Access Denied"); }
$querystr = "SELECT radminsuper, admlanguage FROM ".$prefix."_authors where aid='$aid'";
$result = sql_query($querystr, $dbi) or die ("invalied query");
list($radminsuper) = sql_fetch_row($result, $dbi);
if ($radminsuper==1) {
include("header.php");
GraphicAdmin();
$mysqlservername = $dbname;
$dbcnx = @mysql_connect($dbhost, $dbuname, $dbpass);
if (!$dbcnx) {
echo( "<p>Unable to connect to the " . "database server at this time.</p>" );
exit();
}
if (! @mysql_select_db("$mysqlservername") ) {
echo( "<p>Can't find " . "database.</p>" );
exit();
}
$result = @mysql_query("SELECT * FROM ".$prefix."_squad_forms");
Opentable();
echo "<center><b><u>Welcome to the Squad Forms administration module. Here you can view forms that have been sent by your members.</b></u></center>";
Closetable();
echo "<br><br>";
while ($resultforms = mysql_fetch_array($result)) {
Opentable();
$form_id = $resultforms['form_id'];
$radio = $resultforms['radio'];
$sender_name = $resultforms['sender_name'];
$sender_email = $resultforms['sender_email'];
$sender_aim = $resultforms['sender_aim'];
$sender_msn = $resultforms['sender_msn'];
$sender_icq = $resultforms['sender_icq'];
$sender_yahoo = $resultforms['sender_yahoo'];
$message = $resultforms['message'];
echo "'<a href=\"mailto:$sender_email\">$sender_name</a>' sent an email with the subject of '$radio'.<br>";
if ($radio != "Joining" AND $radio != "Rejoining") {
echo "The message was: <br><hr><center><i>$message</i><br><hr></center>";
}
else {
echo "<br>";
};
echo "Email: <a href=\"mailto:$sender_email\">$sender_email</a><br>";
echo "AIM: <a href=\"aim:goim?screenname=$sender_aim&message=Hi+$sender_aim.+Are+you+there?\">$sender_aim</a><br>";
echo "MSN: $sender_msn<br>";
echo "ICQ: $sender_icq<br>";
echo "Yahoo: $sender_yahoo<br>";
echo "Delete?";
echo "<form ENCTYPE=\"multipart/form-data\" action=\"admin.php?op=squad_forms\" method=\"post\">";
echo "<input type=\"radio\" name=\"deleterecord\" value=\"yes\">Yes<br>";
echo "<input type=\"radio\" name=\"deleterecord\" value=\"no\">No<br>";
if ($deleterecord == "yes") {
$db->sql_query("DELETE FROM ".$prefix."_squad_forms WHERE form_id = $form_id");
}
elseif ($deleterecord == "no") {
}
echo "<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Submit\">";
echo "</FORM>";
Closetable();
echo "<br><br>";
};
include("footer.php");
} else {
echo "Access Denied";
}
?>
|
|
|
|
|
 |
|