Multiple rows in mysql
- gisele
- Expert


- Joined: Nov 11, 2004
- Posts: 583
- Loc: Nimes (France)
- Status: Offline
Well first there's no use a parameter to pass in delete comment function.
$database->DeleteComment("del"); (in the call)
function DeleteProfileComment($del){ (in the class)
you can do this
$database->DeleteComment("del"); )
function DeleteProfileComment($del){ ()
Because $_GET is a superglobal and can be accesses from any where and any context.
just do this :
$q = "DELETE FROM ".TBL_COMMENTS." WHERE ID_FIELD = ".$_GET["del"]." LIMIT 1";
and no parameter for the function , that'll be enough.
Anyway that's not the problem that can work.
In fact the problem seems to be in the comment deleting link .
You use $data["id_comment"] but that was just a generic example, in fact you told be that you had an ID system for the comment but I've got no idea of how you get it just before that's why I put $data["id_comment"] as an example.
I assumed that you retrieved in the same query that retrieves the comments informations.
You should do so anyway, and change my example $data[« id_comment »] by the right value something like $req_user_postusername['something'] (something =>name of the id field)
Ask any question
$database->DeleteComment("del"); (in the call)
function DeleteProfileComment($del){ (in the class)
you can do this
$database->DeleteComment("del"); )
function DeleteProfileComment($del){ ()
Because $_GET is a superglobal and can be accesses from any where and any context.
just do this :
PHP Code: [ Select ]
$q = "DELETE FROM ".TBL_COMMENTS." WHERE ID_FIELD = ".$_GET["del"]." LIMIT 1";
- $q = "DELETE FROM ".TBL_COMMENTS." WHERE ID_FIELD = ".$_GET["del"]." LIMIT 1";
and no parameter for the function , that'll be enough.
Anyway that's not the problem that can work.
In fact the problem seems to be in the comment deleting link .
You use $data["id_comment"] but that was just a generic example, in fact you told be that you had an ID system for the comment but I've got no idea of how you get it just before that's why I put $data["id_comment"] as an example.
I assumed that you retrieved in the same query that retrieves the comments informations.
You should do so anyway, and change my example $data[« id_comment »] by the right value something like $req_user_postusername['something'] (something =>name of the id field)
Ask any question
____________________
My web site[/url] oh sh..!
My web site[/url] oh sh..!
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
July 6th, 2006, 9:19 am
- demonmaestro
- Gold Member


- Joined: Jun 21, 2006
- Posts: 485
- Loc: Conroe, Texas
- Status: Offline
- gisele
- Expert


- Joined: Nov 11, 2004
- Posts: 583
- Loc: Nimes (France)
- Status: Offline
here, see I replaced $data["id_comment"] in that part by $req_user_postusername['comment_id'].
But all is left to do, is replace comment_id by the real name of the ID field in the comment table. In fact I've got no idea of the name you gave to it in the database.
SO the right value will be in that link so that the right value will be passed $_GET["del"]
//...
if(isset($_GET["del"]))
$database->DeleteComment("del");
?> <?php
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['comment_id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
";
}
But all is left to do, is replace comment_id by the real name of the ID field in the comment table. In fact I've got no idea of the name you gave to it in the database.
SO the right value will be in that link so that the right value will be passed $_GET["del"]
PHP Code: [ Select ]
//...
if(isset($_GET["del"]))
$database->DeleteComment("del");
?> <?php
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['comment_id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
";
}
- //...
- if(isset($_GET["del"]))
- $database->DeleteComment("del");
- ?> <?php
- while($req_user_postusername = mysql_fetch_array($rs_pointer))
- {
- echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
- <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
- <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['comment_id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
- ";
- }
- demonmaestro
- Gold Member


- Joined: Jun 21, 2006
- Posts: 485
- Loc: Conroe, Texas
- Status: Offline
ok it will come up with the comment id number but when i click on delete it does nothing and comes up to http://www.gothicgreenwire.com/mycomments.php?del=114 and it says username not registured because it need to say http://www.gothicgreenwire.com/mycommen ... user=admin or what ever there username is.
here is the database php
here is the mycomments php
here is the database php
PHP Code: [ Select ]
function DeleteProfileComment($del){
$q = "DELETE FROM ".TBL_COMMENTS." WHERE id = ".$_GET[$del]." LIMIT 1";
return mysql_query($q, $this->connection);
}
$q = "DELETE FROM ".TBL_COMMENTS." WHERE id = ".$_GET[$del]." LIMIT 1";
return mysql_query($q, $this->connection);
}
- function DeleteProfileComment($del){
- $q = "DELETE FROM ".TBL_COMMENTS." WHERE id = ".$_GET[$del]." LIMIT 1";
- return mysql_query($q, $this->connection);
- }
here is the mycomments php
PHP Code: [ Select ]
<?php //...
if(isset($_GET["del"]))
$database->DeleteComment("del");
?> <?php
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
";
} ?>
if(isset($_GET["del"]))
$database->DeleteComment("del");
?> <?php
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
";
} ?>
- <?php //...
- if(isset($_GET["del"]))
- $database->DeleteComment("del");
- ?> <?php
- while($req_user_postusername = mysql_fetch_array($rs_pointer))
- {
- echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
- <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
- <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
- ";
- } ?>
- gisele
- Expert


- Joined: Nov 11, 2004
- Posts: 583
- Loc: Nimes (France)
- Status: Offline
So no problem just add also this parameter in the target url :
//...
if(isset($_GET["del"]))
$database->DeleteComment("del");
?> <?php
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&del=".$req_user_postusername['comment_id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
";
}
PHP Code: [ Select ]
//...
if(isset($_GET["del"]))
$database->DeleteComment("del");
?> <?php
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&del=".$req_user_postusername['comment_id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
";
}
- //...
- if(isset($_GET["del"]))
- $database->DeleteComment("del");
- ?> <?php
- while($req_user_postusername = mysql_fetch_array($rs_pointer))
- {
- echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
- <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
- <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&del=".$req_user_postusername['comment_id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
- ";
- }
____________________
My web site[/url] oh sh..!
My web site[/url] oh sh..!
- demonmaestro
- Gold Member


- Joined: Jun 21, 2006
- Posts: 485
- Loc: Conroe, Texas
- Status: Offline
- gisele
- Expert


- Joined: Nov 11, 2004
- Posts: 583
- Loc: Nimes (France)
- Status: Offline
argh!
sorry it couldn't work,
I did not take you last script with $req_user_postusername['id']
I cannot test since can't login
try this :
//...
if(isset($_GET["del"]))
$database->DeleteComment("del");
?> <?php
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
";
}
by the way, you should put the user name in the url,
once it'll work you should think about session in PHP.
sorry it couldn't work,
I did not take you last script with $req_user_postusername['id']
I cannot test since can't login
try this :
PHP Code: [ Select ]
//...
if(isset($_GET["del"]))
$database->DeleteComment("del");
?> <?php
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
";
}
- //...
- if(isset($_GET["del"]))
- $database->DeleteComment("del");
- ?> <?php
- while($req_user_postusername = mysql_fetch_array($rs_pointer))
- {
- echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
- <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
- <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
- ";
- }
by the way, you should put the user name in the url,
once it'll work you should think about session in PHP.
- gisele
- Expert


- Joined: Nov 11, 2004
- Posts: 583
- Loc: Nimes (France)
- Status: Offline
- demonmaestro
- Gold Member


- Joined: Jun 21, 2006
- Posts: 485
- Loc: Conroe, Texas
- Status: Offline
here is the new code i added where you have to be loged in also but i still cant figure out why its not working.
PHP Code: [ Select ]
<?php //...
if(isset($_GET["del"]))
$database->DeleteComment("del");
?> <?php
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";
if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&del=".$req_user_postusername['comment_id']."\">Delete Comment</a>";}
echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";
} ?>
if(isset($_GET["del"]))
$database->DeleteComment("del");
?> <?php
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";
if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&del=".$req_user_postusername['comment_id']."\">Delete Comment</a>";}
echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";
} ?>
- <?php //...
- if(isset($_GET["del"]))
- $database->DeleteComment("del");
- ?> <?php
- while($req_user_postusername = mysql_fetch_array($rs_pointer))
- {
- echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
- <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
- <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";
- if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&del=".$req_user_postusername['comment_id']."\">Delete Comment</a>";}
- echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";
- } ?>
- gisele
- Expert


- Joined: Nov 11, 2004
- Posts: 583
- Loc: Nimes (France)
- Status: Offline
noooooo !
The new code you added isn't the last corrected one !
in fact this code is wrong because it kept "del=".$data["id_comment"]." instead in "del=".$req_user_postusername["id"]."
So the right code is :
//...
if(isset($_GET["del"]))
$database->DeleteComment("del");
?> <?php
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
";
}
The new code you added isn't the last corrected one !
in fact this code is wrong because it kept "del=".$data["id_comment"]." instead in "del=".$req_user_postusername["id"]."
So the right code is :
PHP Code: [ Select ]
//...
if(isset($_GET["del"]))
$database->DeleteComment("del");
?> <?php
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
";
}
- //...
- if(isset($_GET["del"]))
- $database->DeleteComment("del");
- ?> <?php
- while($req_user_postusername = mysql_fetch_array($rs_pointer))
- {
- echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
- <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
- <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br><a href=\"".$_SERVER["PHP_SELF"]."?user=".$req_user_postusername['username']."&del=".$req_user_postusername['id']."\">Delete Comment</a></span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>
- ";
- }
- demonmaestro
- Gold Member


- Joined: Jun 21, 2006
- Posts: 485
- Loc: Conroe, Texas
- Status: Offline
actually i fixed it and i ment to post that but for some reason you have to click the link twice to get the comment to delete..
PHP Code: [ Select ]
<?php //...
if(isset($_GET["del"]))
$database->DeleteProfileComment("del");
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";
if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a>";}
echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";
} ?>
if(isset($_GET["del"]))
$database->DeleteProfileComment("del");
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";
if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a>";}
echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";
} ?>
- <?php //...
- if(isset($_GET["del"]))
- $database->DeleteProfileComment("del");
- while($req_user_postusername = mysql_fetch_array($rs_pointer))
- {
- echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
- <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
- <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";
- if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a>";}
- echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";
- } ?>
- gisele
- Expert


- Joined: Nov 11, 2004
- Posts: 583
- Loc: Nimes (France)
- Status: Offline
No in fact that works but the delete function call is between the comment querying stuff and the comments displaying stuff.
SO when you retrived the comments, the delete hasn't been done yet.
And when you click for the second time, the delete stuff was done thow the delete comment is still displayed.
Well in fact I don't know if you get what I try to explain, but anyway you just have to move :
if(isset($_GET["del"]))
$database->DeleteProfileComment("del");
just before
$rs_pointer = $database->getUserComments($req_user);
so that the delete stuff is called before the query that retrieves the comments
did you get that?
SO when you retrived the comments, the delete hasn't been done yet.
And when you click for the second time, the delete stuff was done thow the delete comment is still displayed.
Well in fact I don't know if you get what I try to explain, but anyway you just have to move :
PHP Code: [ Select ]
if(isset($_GET["del"]))
$database->DeleteProfileComment("del");
- if(isset($_GET["del"]))
- $database->DeleteProfileComment("del");
just before
PHP Code: [ Select ]
$rs_pointer = $database->getUserComments($req_user);
- $rs_pointer = $database->getUserComments($req_user);
so that the delete stuff is called before the query that retrieves the comments
did you get that?
- demonmaestro
- Gold Member


- Joined: Jun 21, 2006
- Posts: 485
- Loc: Conroe, Texas
- Status: Offline
it is befor it no?
PHP Code: [ Select ]
<?php //...
if(isset($_GET["del"]))
$database->DeleteProfileComment("del");
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";
if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a>";}
echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";
} ?>
if(isset($_GET["del"]))
$database->DeleteProfileComment("del");
while($req_user_postusername = mysql_fetch_array($rs_pointer))
{
echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
<tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
<br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";
if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a>";}
echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";
} ?>
- <?php //...
- if(isset($_GET["del"]))
- $database->DeleteProfileComment("del");
- while($req_user_postusername = mysql_fetch_array($rs_pointer))
- {
- echo "<table width='100%' border='1' cellpadding='1' cellspacing='1' class=main>
- <tr><td width='24%' align='center' valign='middle' bordercolor='#000000'><div align='center'><span class='main'><a href='userinfo.php?user=".$req_user_postusername['username']."'>".$req_user_postusername['username']."</a><br />
- <br /><a href='comment.php?user=".$req_user_postusername['username']."'>Reply to post!</a><br>";
- if($session->logged_in){ echo"<a href=\"".$_SERVER["PHP_SELF"]."?del=".$req_user_postusername['id']."\">Delete Comment</a>";}
- echo "</span></div></td><td width='74%' bordercolor='#000000'><table width='100%' border='0'><tr><td align='right'>".$req_user_postusername['date']."</span><span class='main'></td></tr><tr><td>".preg_replace('#(\n)#', "<br />", $req_user_postusername['comment'])."</td></tr></table></td></tr></table>";
- } ?>
- gisele
- Expert


- Joined: Nov 11, 2004
- Posts: 583
- Loc: Nimes (France)
- Status: Offline
HI,
not at all, like it is, when you call the comment delete function, the query to retrieve the comments has been yet submitted with :
$rs_pointer = $database->getUserComments($req_user);
and while($req_user_postusername = mysql_fetch_array($rs_pointer)) ...etc. is nothing but a loop that browse the yet built up results set.
so this is like you should order the statments :
//first comment delete stuff :
if(isset($_GET["del"]))
$database->DeleteProfileComment("del");
//then querying the comments in the database :
$rs_pointer = $database->getUserComments($req_user);
and then you can do the displaying stuff ( links and comments )
If you're not sure, just show all the entire comment script and I'll do the changes.
not at all, like it is, when you call the comment delete function, the query to retrieve the comments has been yet submitted with :
$rs_pointer = $database->getUserComments($req_user);
and while($req_user_postusername = mysql_fetch_array($rs_pointer)) ...etc. is nothing but a loop that browse the yet built up results set.
so this is like you should order the statments :
PHP Code: [ Select ]
//first comment delete stuff :
if(isset($_GET["del"]))
$database->DeleteProfileComment("del");
//then querying the comments in the database :
$rs_pointer = $database->getUserComments($req_user);
- //first comment delete stuff :
- if(isset($_GET["del"]))
- $database->DeleteProfileComment("del");
- //then querying the comments in the database :
- $rs_pointer = $database->getUserComments($req_user);
and then you can do the displaying stuff ( links and comments )
If you're not sure, just show all the entire comment script and I'll do the changes.
- demonmaestro
- Gold Member


- Joined: Jun 21, 2006
- Posts: 485
- Loc: Conroe, Texas
- Status: Offline
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
July 8th, 2006, 6:49 am
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 97 posts
- Users browsing this forum: No registered users and 141 guests
- 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 post attachments in this forum
