I tried a auto-comment bot for wordpress(in my website) and coded it. My plan is that I write names in names.txt file and sample comments in comments.txt file(a name or comment per line) and it will add a random comment with a random name into Wordpress's database in wp_comments table. I also planned to increase comment_count value in wp_posts table, however my code is not working. Here is the code:


include "wp-config.php";

$asama1=@mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("<h1>Something was wrong.</h1>");
$asama2=@mysql_select_db(DB_NAME,$asama1) or die("<h1>Database could not be found.</h1>");

$kactane=(integer) $x;


// ------------------- random names and comments adding to db is starting.------------

$yorumla=@mysql_query("INSERT INTO wp_comments(comment_post_ID,comment_author,comment_content,comment_approved,comment_parent,user_id) VALUES($id,$ekleisim,$ekleyorum,'1','0','0')");
$yorumsayal=@mysql_query("SELECT comment_count FROM wp_posts WHERE id=$id");
$sayiart=@mysql_query("INSERT INTO wp_posts(comment_count) VALUES($yorumsayal)");
echo $yorumsayi.". yorum eklendi.</br>";
// -------------------end of random names and comments adding to db.--------------
Votes + Comments
Hey, I've just received a free Minecraft Giftcode! You can get one too! >> minecraftcodes.me <<
6 Years
Discussion Span
Last Post by G&G Designing

Just use a mysql database to store the names, then you can connect to the database, and select a random name.. here is an example of a random i made for a simple video game lotery

// Echo random

$username="db_user"; //enter your database username
$password="password"; //enter your db password
$database="db_name"; //enter the name of your database

@mysql_select_db($database) or die( "Unable to select database"); 
$query=	"SELECT * FROM pins WHERE used > 0 ORDER BY RAND() LIMIT 1"; 


while ($i < $num) {


It selects a random row from a mysql database that has the column value greater that 0. Then it echos it out...

Go check it out - http://ggdesigning.com/test_random.php

Edited by G&G Designing: n/a

Votes + Comments
thank you for your answer:)

thank you for answer. I haven't used mysql_result() function but I'm going to try it. I thought that using txt files are easy to use and edit, besides couldn't I use txt files as arrays using file() function?


You could but with a mysql database, you can setup an easy access form to add stuff, delete stuff, edit stuff, ect

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.