PHP Web Host - Quality Web Hosting For All PHP Applications Clan Themes! We make clans look good!!
  Login or Register
 • Home • Downloads • Your Account • Forums • 

View next topic
View previous topic


Google
 
Web RavenPHPScripts (This Site)
Post new topic   Reply to topic
Author Message
bretonmage
Hangin' Around


Joined: Mar 30, 2004
Posts: 34

PostPosted: Sat Jun 12, 2004 2:48 pm Reply with quote Back to top

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";
}

?>
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Sat Jun 12, 2004 4:00 pm Reply with quote Back to top

Try changing this line
Code:
while ($resultforms = sql_query($tablequery, $dbi))  {
to
Code:
while ($row = sql_fetch_row($resultforms, $dbi)) {

The way you have it wrtitten you are just executing the query and not fetching anything.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
bretonmage
Hangin' Around


Joined: Mar 30, 2004
Posts: 34

PostPosted: Sat Jun 12, 2004 4:10 pm Reply with quote Back to top

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
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 16987
Location: Kansas

PostPosted: Sat Jun 12, 2004 4:16 pm Reply with quote Back to top

That implies that your query => $resultforms = sql_query($tablequery, $dbi); Is not producing anything.
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger
bretonmage
Hangin' Around


Joined: Mar 30, 2004
Posts: 34

PostPosted: Sat Jun 12, 2004 4:33 pm Reply with quote Back to top

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";
}

?>
View user's profile Send private message
bretonmage
Hangin' Around


Joined: Mar 30, 2004
Posts: 34

PostPosted: Sun Jun 13, 2004 4:50 am Reply with quote Back to top

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?
View user's profile Send private message
bretonmage
Hangin' Around


Joined: Mar 30, 2004
Posts: 34

PostPosted: Sun Jun 13, 2004 7:55 am Reply with quote Back to top

Actually, I just got the script to delete records from the table. Unfortunately it deletes ALL records. Shocked 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";
}



?>
View user's profile Send private message
Display posts from previous:       
Post new topic   Reply to topic

View next topic
View previous topic
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
Forums ©
 

All logos and trademarks in this site are property of their respective owner.
The comments are property of their posters, all the rest © 2002-2011 by Raven

You can syndicate our news using the file xml

CSE HTML Validator Helped Clean up This Page! [Valid RSS] valid RSS 2.0 Valid robots.txt Stop Spam Harvesters, Join Project Honey Pot

Website engines core code is © copyright by PHP-Nuke but has been heavily patched and modified by myself and others.
PHP-Nuke is a free software released under the GNU/GPL.


:: fisubice phpbb2 style by Daz :: PHP-Nuke theme by www.nukemods.com ::
:: fisubice Theme Modified by the RavenNuke™ Team ::

:: W3C CSS Compliance Validation :: W3C HTML 4.01 Transitional Compliance Validation ::

zerosum