简体   繁体   English

PHP / Ajax聊天/ MYSql-在聊天室中创建假用户

[英]PHP/Ajax Chat/MYSql - Create fake users in chat room

I am using Ajax Free Chat on my server. 我在服务器上使用Ajax Free Chat。 I would like to have a couple of fake users logged in to get things going. 我希望有几个假用户登录才能使事情进展顺利。 But I dont know how to implement these using PHP/mysql. 但是我不知道如何使用PHP / mysql来实现它们。

I have found there is a database table called 'online' which displays the logged in users on the user list within the chat. 我发现有一个名为“在线”的数据库表,该表在聊天中的用户列表上显示已登录的用户。 Maybe its this table I need to edit? 也许我需要编辑此表? Any help reatly appreciated. 任何帮助深表感谢。

function addToOnlineList() {
    $sql = 'INSERT INTO '.$this->getDataBaseTable('online').'(
        userID,
        userName,
        userRole,
        channel,
        dateTime,
        ip
    )
    VALUES (
        '.$this->db->makeSafe($this->getUserID()).',
        '.$this->db->makeSafe($this->getUserName()).',
        '.$this->db->makeSafe($this->getUserRole()).',
        '.$this->db->makeSafe($this->getChannel()).',
        NOW(),
        '.$this->db->makeSafe($this->ipToStorageFormat($_SERVER['REMOTE_ADDR'])).'
    );';

According to your comments that what you should do 根据您的意见,您应该做什么

First you need to get sure that you are connected to the database if not use this 首先,如果不使用此功能,则需要确保已连接到数据库

$connection = mysql_connect("localhost","username","password");
mysql_select_db("dbname",$connection); 

next 下一个

function addToOnlineList() {
    $sql = 'INSERT INTO '.$this->getDataBaseTable('online').'(
        userID,
        userName,
        userRole,
        channel,
        dateTime,
        ip
    )
    VALUES (
        '.$this->db->makeSafe($this->getUserID()).',
        '.$this->db->makeSafe($this->getUserName()).',
        '.$this->db->makeSafe($this->getUserRole()).',
        '.$this->db->makeSafe($this->getChannel()).',
        NOW(),
        '.$this->db->makeSafe($this->ipToStorageFormat($_SERVER['REMOTE_ADDR'])).'
    );';
//here what you should add 
mysql_query($sql) or die(mysql_error());



}

If you know what the values like $this->getUserID() the above will work if not you should replace them with some values from you Good Luck if you need more help just comment 如果您知道像$this->getUserID()这样的值,那么上面的方法可以正常工作,如果您需要更多帮助,则应该用好运中的一些值替换它们,只需注释

Edit this is how you can generate a simple data 编辑这就是您可以生成简单数据的方式

$names = array("namee1","name2","name3","will");
echo $names[array_rand($names)]; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM