Author |
Message |
scorpious
Worker


Joined: Dec 03, 2005
Posts: 153
|
Posted:
Sat Mar 29, 2008 5:32 am |
|
Hi all
I have done this module it seams to work fine, it shows the database information needed. But, when I click on the delete button I get the error message Sorry, that module file was not found [ Go Back ]
In the address bar I see http://address.com/modules.php?del=25
Below is the code inthe index.file, on the last echo statement where the delete button is I have <a href='?del=".$id."'>Delete I think its this part that is causeing the error. all it should do is delete the information from the database.
Code:<?php
if (!eregi("modules.php", $_SERVER['SCRIPT_NAME'])) {
die ("You can't access this file directly...");
}
require_once("mainfile.php");
define('INDEX_FILE', true);
$module_name = basename(dirname(__FILE__));
include("header.php");
//
mysql_connect("Localhost","Username","Password");
// Change the above line
mysql_select_db("DBName");
OpenTable();
echo "<tr><td>ID</td><td>Song</td><td></td><td>Artist</td><td></td><td>Requested by</td><td></td><td>IP</td><td>Delete</td></tr>";
// $requested = $db->sql_query('SELECT id, id, song, artist, name, ip, name FROM request_song ORDER BY id LIMIT 6');
if ($_GET['del']) {
$delete = $_GET['del'];
$delque = "DELETE FROM request_song WHERE id='{$delete}'";
mysql_query($delque);
}
$query = "SELECT * FROM request_song ORDER BY id LIMIT 10";
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
$id = $row['id'];
$song = $row['song'];
$artist = $row['artist'];
$name = $row['name'];
$ip = $row['ip'];
echo "<tr><td>".$id."</td><td>".$song."</td><td></td><td>".$artist."</td><td></td><td>".$name."</td><td></td><td>".$ip."</td><td><a href='?del=".$id."'>Delete</a></td></tr>";
}
CloseTable();
include("footer.php");
?>
|
Edited by admin to wrap the code around BBCode Code tags... |
|
|
|
 |
montego
Site Admin

Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Sat Mar 29, 2008 7:35 am |
|
scorpious, please wrap your code within BBCode Code tags... I have modified your post above as such.
First of all, although not really a part of your question, since you are including this with *nuke as a module and you are already including mainfile.php, you already have a connection to your database. You might want to use the $db object instead (see other nuke modules for examples). Of course, if this is intentional in order to go against another database, then you have to do what you are doing.
Now to you question. You are telling it to do this within your code here:
Take a look at other modules and the links there, they are all of the form:
href="modules.php?name=<NameOfYourModule>&other args..."
You need to include the "modules.php?name=.......&del=" |
_________________ Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! |
|
|
 |
scorpious

|
Posted:
Sat Mar 29, 2008 1:25 pm |
|
Hi Montego
This is what I have now:
<a href='modules.php?name=Requested&?del=".$id."'>
Which stops the Error Message, But, The delete is not working now lol
Cheers Scorp |
|
|
|
 |
montego

|
Posted:
Sat Mar 29, 2008 1:51 pm |
|
Well, it has to be valid URL string. Remove the extra "?" that you have after the "&" sign in front of the "del". |
|
|
|
 |
scorpious

|
Posted:
Sat Mar 29, 2008 5:46 pm |
|
|
|
 |
montego

|
Posted:
Sat Mar 29, 2008 9:03 pm |
|
|
|
 |
scorpious

|
Posted:
Sun Mar 30, 2008 12:42 pm |
|
Hi Montego
Sorry completely read it wrong lol ( was tired if thats a good excuse )
Worked like a charm
Cheers for your advise and help once again
Scorp |
|
|
|
 |
scorpious

|
Posted:
Sun Mar 30, 2008 3:46 pm |
|
Hi
I have created a module called Request
Once I hits the request button these are the errors I get:
Code:// User Input Area
// echo '<form method=\"post\" action=\"modules.php?name=$module_name\">'; // Webpage can not be found
// echo "<form method=\"post\" action=\"modules.php?name=$module_name\">"; // Sorry, that module file was not found.
// echo '<form method=\"post\" action=\"modules.php?name=Request\">'; // Webpage can not be found
// echo '<form action="modules.php?name=Request" method="POST">'; // Sorry, that module file was not found.
// echo "<form name=\"Request\" action=\"modules.php?name=$module_name\" method=\"post\">"; // Sorry, that module file was not found.
echo '<form action="index.php" method="POST">'; // This works but takes the user back to the root index.php
|
I need the page to refresh and then stay inside the module
Cheers Scorp |
|
|
|
 |
Gremmie
Former Moderator in Good Standing

Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA
|
Posted:
Sun Mar 30, 2008 4:50 pm |
|
Try
Code:
echo '<form method="post" action="modules.php?name=', $module_name, '">';
|
You might want to brush up on your use of quotes in PHP.  |
_________________ Only registered users can see links on this board! Get registered or login! - An Event Calendar for PHP-Nuke
Only registered users can see links on this board! Get registered or login! - A Google Maps Nuke Module |
|
|
 |
scorpious

|
Posted:
Sun Mar 30, 2008 4:54 pm |
|
Hi Gremmie
Tried that and got Sorry, that module file was not found.
These is the request block, I thought I try and turn it into a module
Scorp |
|
|
|
 |
Guardian2003
Site Admin

Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam
|
Posted:
Sun Mar 30, 2008 5:33 pm |
|
I think the forum messed with Gremmies code.
Before and after $module_name it should be a full-stop . not a comma , |
|
|
|
 |
Gremmie

|
Posted:
Sun Mar 30, 2008 5:36 pm |
|
scorpious, here is a tip. Do a view source on your page in your browser and look at the generated HTML. Use that to guide you on what you need to do in your PHP code.
Guardian2003, you must have missed the thread where we discovered that PHP echo takes a comma separated list of arguments. It's actually faster to do it that way than to concatenate with the . operator.  |
|
|
|
 |
Gremmie

|
Posted:
Sun Mar 30, 2008 5:39 pm |
|
For example, is that code inside a function? If so you may need a global statement for $module_name. Look at the generated code and post it here. |
|
|
|
 |
Guardian2003

|
Posted:
Sun Mar 30, 2008 6:19 pm |
|
Gremmie wrote: | Guardian2003, you must have missed the thread where we discovered that PHP echo takes a comma separated list of arguments. It's actually faster to do it that way than to concatenate with the . operator. |
Wow, yes I did miss that one - interesting  |
|
|
|
 |
scorpious

|
Posted:
Mon Mar 31, 2008 4:24 am |
|
Hi All
Here is the code I am using.
Code:<?php
if (!eregi("modules.php", $_SERVER['SCRIPT_NAME'])) {
die ("You can't access this file directly...");
}
require_once("mainfile.php");
define('INDEX_FILE', true);
$module_name = basename(dirname(__FILE__));
include("header.php");
global $prefix, $db;
OpenTable();
$reg = "yes";
$ip = $_SERVER['REMOTE_ADDR'];
echo "<center>Your ip is: ".$ip."</center><br />";
//
if (isset($_POST['submit'])) {
if (empty($_POST['song'])) {
echo "Sorry, you haven't supplied the song title!<br />";
$reg = "no";
}
if (empty($_POST['artist'])) {
echo "Sorry, you haven't supplied the artists name!<br />";
$reg = "no";
}
if (empty($_POST['name'])) {
echo "Sorry, you haven't supplied your name<br />";
$reg = "no";
}
$result = mysql_query($sql);
if (mysql_result($result, 0) > 0) {
echo "Sorry, your ip has already wished for one song, you can not wish for <br />another until the DJ's have seen your request!<br />";
$reg = "no";
}
if ($reg == "yes") {
$sql = "INSERT INTO request_song(song, artist, name, ip)
VALUES('{$_POST['song']}', '{$_POST['artist']}', '{$_POST['name']}', '{$ip}')";
mysql_query($sql);
}
}
// User Input Area
// What i have tried and the erros at the end
// echo '<form method=\"post\" action=\"modules.php?name=$module_name\">'; // Webpage can not be found
// echo "<form method=\"post\" action=\"modules.php?name=$module_name\">"; // Sorry, that module file was not found.
// echo '<form method=\"post\" action=\"modules.php?name=Request\">'; // Webpage can not be found
// echo '<form action="modules.php?name=Request" method="POST">'; // Sorry, that module file was not found.
// echo "<form name=\"Request\" action=\"modules.php?name=$module_name\" method=\"post\">"; // Sorry, that module file was not found.
// echo '<form method="post" action="modules.php?name='. $module_name. '">'; // Sorry, that module file was not found.
echo '<form action="index.php" method="POST">'; // This works but takes the user back to the root index.php
echo '<table>';
echo '<tr><td>Song title: </td><td><input type="text" name="song" value=""></td></tr>';
echo '<tr><td>Artist: </td><td><input type="text" name="artist" value=""></td></tr>';
echo '<tr><td>Your name: </td><td><input type="text" name="name" value=""></td></tr>';
echo '</table>';
echo '<input type="submit" name="submit" value="Send!">';
echo '</form>';
//
CloseTable();
include("footer.php");
?>
|
Cheers Scorp |
|
|
|
 |
Gremmie

|
Posted:
Mon Mar 31, 2008 7:16 am |
|
I still think this should work:
Code:
echo '<form method="post" action="modules.php?name=', $module_name, '">';
|
Where is this file located? Is it called modules/Requested/index.php? |
|
|
|
 |
scorpious

|
Posted:
Mon Mar 31, 2008 7:41 am |
|
Hi Gremmie
It is called modules/Request/index.php?
same error Sorry, that module file was not found. lol
scorp |
|
|
|
 |
Gremmie

|
Posted:
Mon Mar 31, 2008 8:04 am |
|
Ok, you were saying Requested above, so are you sure Request is correct? And you have activated the module in the control panel?
Do a "view source" on the page showing the form. Search for the <form> line in the source, what does it look like there? |
|
|
|
 |
scorpious

|
Posted:
Mon Mar 31, 2008 8:47 am |
|
Hi Gremmie
I have two modules 1 called Request and the other called requested < (admin only)
The rquested module works great now. I have posted within the same topic for another problem with the request module.
When I view in page source this is what I get
Code:<center>Your ip is: 77.100.17.141</center><br /><form method="post" action="modules.php?name=Request"><table><tr><td>Song title: </td><td><input type="text" name="song" value=""></td></tr><tr><td>Artist: </td><td><input type="text" name="artist" value=""></td></tr><tr><td>Your name: </td><td><input type="text" name="name" value=""></td></tr></table><input type="submit" name="submit" value="Send!"></form>
|
Yes the module is active
Scorp |
|
|
|
 |
|