PDA

View Full Version : SQL Help :)



Assassinator
28-09-2007, 07:26 PM
Ok well basicly, i want it so when you press "Delete" it replace's the text someone post's.

I.e if someone posted "Omg idiot" And i clicked Delete, i want the post to say "This post has been removed by $username who is moderating the forum"

Here is my code (At the moment it just delete's the post)


<?
session_start();
include "includes/db_connect.php";
include "includes/functions.php";
include"includes/smile.php";
logincheck();
$forum=$_GET['forum'];
$username=$_SESSION['username'];
$viewtopic = $_GET['viewtopic'];
$forum_look=$_GET['forum_look'];
$fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));

if($_GET[clean]) {
$clean=$_GET[clean];
if($fetch->userlevel == "2" || $fetch->userlevel == "0") { die('You cannot delete this post!'); }
mysql_query("DELETE FROM replys WHERE id='$clean' AND forum='$forum'") or die ("<font color=white>Cannot delete reply</font>");
echo "<font color=white>Reply Deleted</font>!";
echo "<meta http-equiv='refresh' content='1;url=right.php?forum=$forum&viewtopic=$viewtopic'>";
}
if (!$viewtopic){
$viewtopic = "1";
}

Eccentric
28-09-2007, 08:30 PM
what you need to do is edit the current sql with the message you want to display i honestly cant remember the sql i was thinking it will come to me ina min :)

RichardKnox
29-09-2007, 11:16 AM
Whats the name in the db for the field with the content?

Assassinator
29-09-2007, 01:52 PM
Whats the name in the db for the field with the content?

Erm text.

Invent
29-09-2007, 02:01 PM
<?php
session_start();
include "includes/db_connect.php";
include "includes/functions.php";
include"includes/smile.php";
logincheck();
$forum=$_GET['forum'];
$username=$_SESSION['username'];
$viewtopic = $_GET['viewtopic'];
$forum_look=$_GET['forum_look'];
$fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));

if($_GET[clean]) {
$clean=$_GET[clean];
if($fetch->userlevel == "2" || $fetch->userlevel == "0") { die('You cannot delete this post!'); }
mysql_query("UPDATE `replys` SET `text` = 'This post has been removed by $username who is moderating the forum' WHERE id='$clean' AND forum='$forum'") or die ("<font color=white>Cannot delete reply</font>");
echo "<font color=white>Reply Deleted</font>!";
echo "<meta http-equiv='refresh' content='1;url=right.php?forum=$forum&viewtopic=$viewtopic'>";
}
if (!$viewtopic){
$viewtopic = "1";
}

Assassinator
29-09-2007, 02:07 PM
<?php
session_start();
include "includes/db_connect.php";
include "includes/functions.php";
include"includes/smile.php";
logincheck();
$forum=$_GET['forum'];
$username=$_SESSION['username'];
$viewtopic = $_GET['viewtopic'];
$forum_look=$_GET['forum_look'];
$fetch=mysql_fetch_object(mysql_query("SELECT * FROM users WHERE username='$username'"));

if($_GET[clean]) {
$clean=$_GET[clean];
if($fetch->userlevel == "2" || $fetch->userlevel == "0") { die('You cannot delete this post!'); }
mysql_query("UPDATE `replys` SET `text` = 'This post has been removed by $username who is moderating the forum' WHERE id='$clean' AND forum='$forum'") or die ("<font color=white>Cannot delete reply</font>");
echo "<font color=white>Reply Deleted</font>!";
echo "<meta http-equiv='refresh' content='1;url=right.php?forum=$forum&viewtopic=$viewtopic'>";
}
if (!$viewtopic){
$viewtopic = "1";
}


I could marry you. xx

Want to hide these adverts? Register an account for free!