Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
scorpious
Worker
Worker



Joined: Dec 03, 2005
Posts: 153

PostPosted: Sat Mar 29, 2008 5:32 am Reply with quote

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 [ Only registered users can see links on this board! Get registered or login! ]

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...
 
View user's profile Send private message
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Sat Mar 29, 2008 7:35 am Reply with quote

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:

Code:
href='?del=".$id."


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="

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
scorpious







PostPosted: Sat Mar 29, 2008 1:25 pm Reply with quote

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







PostPosted: Sat Mar 29, 2008 1:51 pm Reply with quote

Well, it has to be valid URL string. Remove the extra "?" that you have after the "&" sign in front of the "del".
 
scorpious







PostPosted: Sat Mar 29, 2008 5:46 pm Reply with quote

Hi Montego

I now have <a href='modules.php?name=Requested?del=".$id."'> and now the error is Sorry, that module file was not found.
[ Go Back ]

These is what is in the address bar [ Only registered users can see links on this board! Get registered or login! ]

Requested is that module name.

Cheers scorp
 
montego







PostPosted: Sat Mar 29, 2008 9:03 pm Reply with quote

You misread my post. You needed to lose the extra "?" no the "&". The URL string that you posted is not valid. Might this work a bit better???
[ Only registered users can see links on this board! Get registered or login! ]

Wink
 
scorpious







PostPosted: Sun Mar 30, 2008 12:42 pm Reply with quote

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







PostPosted: Sun Mar 30, 2008 3:46 pm Reply with quote

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

PostPosted: Sun Mar 30, 2008 4:50 pm Reply with quote

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. Smile

_________________
GCalendar - An Event Calendar for PHP-Nuke
Member_Map - A Google Maps Nuke Module 
View user's profile Send private message
scorpious







PostPosted: Sun Mar 30, 2008 4:54 pm Reply with quote

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

PostPosted: Sun Mar 30, 2008 5:33 pm Reply with quote

I think the forum messed with Gremmies code.
Before and after $module_name it should be a full-stop . not a comma ,
 
View user's profile Send private message Send e-mail
Gremmie







PostPosted: Sun Mar 30, 2008 5:36 pm Reply with quote

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. Smile
 
Gremmie







PostPosted: Sun Mar 30, 2008 5:39 pm Reply with quote

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







PostPosted: Sun Mar 30, 2008 6:19 pm Reply with quote

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. Smile

Wow, yes I did miss that one - interesting Smile
 
scorpious







PostPosted: Mon Mar 31, 2008 4:24 am Reply with quote

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







PostPosted: Mon Mar 31, 2008 7:16 am Reply with quote

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







PostPosted: Mon Mar 31, 2008 7:41 am Reply with quote

Hi Gremmie

It is called modules/Request/index.php?

same error Sorry, that module file was not found. lol

scorp
 
Gremmie







PostPosted: Mon Mar 31, 2008 8:04 am Reply with quote

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







PostPosted: Mon Mar 31, 2008 8:47 am Reply with quote

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
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

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
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©