ajloun
09-11-2009, 08:32 AM
Hello
I have Sql Tabel.
CREATE TABLE comment (
xid int(11) NOT NULL auto_increment,
name varchar(100) NOT NULL default '',
email varchar(100) NOT NULL default '',
font_color varchar(100) NOT NULL default '',
comment mediumtext NOT NULL,
submitter int(11) NOT NULL default '0',
ip varchar(100) NOT NULL default '',
date int(10) NOT NULL default '0',
PRIMARY KEY (xid)
) TYPE=MyISAM;
This for post Comments
Now i use this to try get the total of Comments
$sql =mysql_query("SELECT * FROM comment")
or die("can't select the comment");
$total_comment=mysql_affected_rows($sql);
But i get this error
Warning: mysql_affected_rows(): supplied resource is not a valid MySQL-Link resource in file
i tried to use another function but same error
$total_ehdaa=mysql_num_rows($query);
For the Records . wht i'm trying to do is , delete a Number of Comment in Certin limits
Full code
$limit= "1";
$sql =mysql_query("SELECT * FROM comment")
or die("can't select the comment");
$total_ehdaa=mysql_affected_rows($sql);
$diff= $total_ehdaa - $limit ;
if ($diff<=0) { echo"No old Comment";}else{
$query2= mysql_query("delete from comment LIMIT $diff") or die ("cann't delete");
if (!$query2){
echo"<center>There SOme errors </center><META HTTP-EQUIV=\"Refresh\" Content=3;URL=\"index.php\">";
}else{
echo"<center>Delted!!<br>Will Take you Back to where u come from</center><META HTTP-EQUIV=\"Refresh\" Content=5;URL=\"index.php\">";
}
}
I have Sql Tabel.
CREATE TABLE comment (
xid int(11) NOT NULL auto_increment,
name varchar(100) NOT NULL default '',
email varchar(100) NOT NULL default '',
font_color varchar(100) NOT NULL default '',
comment mediumtext NOT NULL,
submitter int(11) NOT NULL default '0',
ip varchar(100) NOT NULL default '',
date int(10) NOT NULL default '0',
PRIMARY KEY (xid)
) TYPE=MyISAM;
This for post Comments
Now i use this to try get the total of Comments
$sql =mysql_query("SELECT * FROM comment")
or die("can't select the comment");
$total_comment=mysql_affected_rows($sql);
But i get this error
Warning: mysql_affected_rows(): supplied resource is not a valid MySQL-Link resource in file
i tried to use another function but same error
$total_ehdaa=mysql_num_rows($query);
For the Records . wht i'm trying to do is , delete a Number of Comment in Certin limits
Full code
$limit= "1";
$sql =mysql_query("SELECT * FROM comment")
or die("can't select the comment");
$total_ehdaa=mysql_affected_rows($sql);
$diff= $total_ehdaa - $limit ;
if ($diff<=0) { echo"No old Comment";}else{
$query2= mysql_query("delete from comment LIMIT $diff") or die ("cann't delete");
if (!$query2){
echo"<center>There SOme errors </center><META HTTP-EQUIV=\"Refresh\" Content=3;URL=\"index.php\">";
}else{
echo"<center>Delted!!<br>Will Take you Back to where u come from</center><META HTTP-EQUIV=\"Refresh\" Content=5;URL=\"index.php\">";
}
}