"DB error, create SQL table before"

MaxiBash

Your Local Random Internet Geek
OP
Member
Joined
Jul 14, 2018
Messages
1,287
Trophies
1
Website
trashbandatcootofficial.cardd.co
XP
5,024
Country
Netherlands
I just wan't to learn how to manage an online chat. I found a source, added that to my website, but it gives this error anytime I open or refresh the page:

DB error, create SQL table before
This is the site: http://choconut.epizy.com/

I found an answer and he said that I need to make sure I already configured my "DB" (which I assume stands for DataBase) details in the 'inc/chat.inc.php' file.

This is the source https://www.script-tutorials.com/demos/6/source.zip and I assume this problem is pinpointed to 'sql.sql' and 'chat.inc.php'.
Can someone help me fix this issue?
Thanks!
 

BigPanda

Well-Known Member
Member
Joined
Jul 18, 2016
Messages
221
Trophies
0
XP
1,719
Country
Belgium
On the chat.inc.php you have setup the value for $this->sDbName = 'database_name';

You need to ensure that you have created a database inside your mysql server that is named the same as the word written between single quotes.

You might want to understand the basic of mySQL and have a minimum understanding for reading (not coding) PHP files.

https://www.w3schools.com/
 
Last edited by BigPanda,

MaxiBash

Your Local Random Internet Geek
OP
Member
Joined
Jul 14, 2018
Messages
1,287
Trophies
1
Website
trashbandatcootofficial.cardd.co
XP
5,024
Country
Netherlands
Something like this?
Still didn't work, the error still displayed on the site.
 

Attachments

  • php.png
    php.png
    3.7 KB · Views: 269

fadx

Filthy Cheater
Member
Joined
Sep 15, 2016
Messages
430
Trophies
0
XP
2,453
Country
United Kingdom
Looks like it wants you to use the query provided in sql.sql to create a table to work with.
In your database run the sql.sql file or run the following query:
Code:
CREATE TABLE `s_chat_messages` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`user` VARCHAR( 255 ) NOT NULL ,
`message` VARCHAR( 255 ) NOT NULL ,
`when` INT( 11 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

EDIT: You don't need to name your database "sql.sql". You basically make your database and name it anything e.g. "simplechat", you assign a database user to that database and then you'd use "simplechat" (or whatever you called your database) in place of "database_name" in chat.inc.php then in place of "username" you'd have the user you assigned to the database and then for "password" you'd put that users password. You should then use the query I mentioned above on the database you made and then "SimpleChat" should have no problem communicating with the database.
 
Last edited by fadx,

MaxiBash

Your Local Random Internet Geek
OP
Member
Joined
Jul 14, 2018
Messages
1,287
Trophies
1
Website
trashbandatcootofficial.cardd.co
XP
5,024
Country
Netherlands
It still doesn’t work.
I changed it to “ChocoNut.sql”, made sure everything in the PHP files was attatched to it, and it still gives the same error.

In your database run the sql.sql file or run the following query

It doesn’t give me the options to run a query or file, only to edit, delete rename or add files.
 

fadx

Filthy Cheater
Member
Joined
Sep 15, 2016
Messages
430
Trophies
0
XP
2,453
Country
United Kingdom
It still doesn’t work.
I changed it to “ChocoNut.sql”, made sure everything in the PHP files was attatched to it, and it still gives the same error.



It doesn’t give me the options to run a query or file, only to edit, delete rename or add files.

Do you have an SQL database setup? The .sql file is not the database, it's a file that you'll use to tell the a database you already have what table it should make.

In your web panel there should be a section called "DATABASES", within that section click on "MySQL Databases".
Enter a name for the database e.g. simplechat.
It'll make the database and the information will be below.
Some example information would be:
DB Name: epiz_12345678_simplechat
User Name: epiz_12345678
Password: "YOUR_CPANEL_PASS"
HostName: sql123.epizy.com

With that information you'd open up chat.inc.php and change the following:
Code:
    function SimpleChat() {
        //mysql_connect("localhost","username","password");
        $this->sDbName = 'database_name';
        $this->sDbUser = 'username';
        $this->sDbPass = 'password';
    }
to this:
Code:
    function SimpleChat() {
        //mysql_connect("localhost","username","password");
        $this->sDbName = 'epiz_12345678_simplechat';
        $this->sDbUser = 'epiz_12345678';
        $this->sDbPass = 'YOUR_CPANEL_PASS';
    }

After you've done that, you'll want to replace every instance of "localhost" to the host name, which in this example would be "sql123.epizy.com".

Once you've done all this you'll want to go back to your websites control panel and under "DATABASES" select "phpMyAdmin".
Once here click "Connect now!" next to the database you just created.
You'll be brought to a page with tabs at the top, click the tab that says "SQL".
Inside that box put the following:
Code:
CREATE TABLE `s_chat_messages` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`user` VARCHAR( 255 ) NOT NULL ,
`message` VARCHAR( 255 ) NOT NULL ,
`when` INT( 11 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Then at the bottom right click "Go".
It should hopefully say something like "Your SQL query has been executed successfully ( Query took 0.0123 sec )" at the top of the page.
You can then click the "Structure" tab at the top and hopefully a table should be there called "s_chat_messages".
Hopefully your website should now be able to communicate with the database.
 
Last edited by fadx,

MaxiBash

Your Local Random Internet Geek
OP
Member
Joined
Jul 14, 2018
Messages
1,287
Trophies
1
Website
trashbandatcootofficial.cardd.co
XP
5,024
Country
Netherlands
Oh,
I accessed that panel yesterday and for whatever reason it doesn't work anymore.
Anytime I try it says it was unable with the info I gave. I tried relogging in, and it doesn't seem to send me a mail for a password reset either.

I'm now completely lost for no reason :(

Edit: And now I completely lost access. Just another day where nothing works!
 
Last edited by MaxiBash,

fadx

Filthy Cheater
Member
Joined
Sep 15, 2016
Messages
430
Trophies
0
XP
2,453
Country
United Kingdom

MaxiBash

Your Local Random Internet Geek
OP
Member
Joined
Jul 14, 2018
Messages
1,287
Trophies
1
Website
trashbandatcootofficial.cardd.co
XP
5,024
Country
Netherlands
// constructor
function SimpleChat() {
//mysql_connect("sql303.epizy.com","username","password");
$this->sDbName = 'epiz_[number]_SimpleChat';
$this->sDbUser = 'epiz_[number]';
$this->sDbPass = '(Why would you ever want to know my password, you wank?)';
}

This is what I wrote, still doesn't work.
 

fadx

Filthy Cheater
Member
Joined
Sep 15, 2016
Messages
430
Trophies
0
XP
2,453
Country
United Kingdom
Did you execute the query I posted in phpMyAdmin to create the table?

Also there's multiple of instances of localhost that would need to be replaced with the sql303.epizy.com

EDIT: This will make it easier.
Copy all the text here: https://pastebin.com/raw/fvW1Ah2v
Delete all the text in chat.inc.php and replace it with the text you copied.
On lines 15, 16, 17 and 18 replace 'HOST', 'DATABASE', 'USERNAME' and 'PASSWORD' with the correct information.

For whatever reason the example code they give you doesn't take into account that you might not be using localhost for the database and therefore it doesn't create a host variable to be used. If you use the code from that pastebin it should just be as simple as putting the correct info on those 4 line.
 
Last edited by fadx,

MaxiBash

Your Local Random Internet Geek
OP
Member
Joined
Jul 14, 2018
Messages
1,287
Trophies
1
Website
trashbandatcootofficial.cardd.co
XP
5,024
Country
Netherlands
Yes, I executed the query, and double checked that s_chat_messages is there.
It is.
I will now replace the text I got in Pastebin but it's such a hassle.
I can't change the password and when I accidently put in the wrong info it automaticly blocks and I can't login for 5 minutes.
 

MaxiBash

Your Local Random Internet Geek
OP
Member
Joined
Jul 14, 2018
Messages
1,287
Trophies
1
Website
trashbandatcootofficial.cardd.co
XP
5,024
Country
Netherlands
Also, I'm wondering if you could help me with this:
The accounts are User1, User2 and User3 and all share a bad password.
I want to make my own account but I can't find anywhere in any file how to edit, delete or add users.
All I could find was this in login.inc.php:
01 <?
02 // class SimpleLoginSystem
03 class SimpleLoginSystem {
04 // variables
05 var $aExistedMembers; // Existed members array
06 // constructor
07 function SimpleLoginSystem() {
08 $this->aExistedMembers = array(
09 'User1' => 'd8578edf8458ce06fbc5bb76a58c5ca4',
10 'User2' => 'd8578edf8458ce06fbc5bb76a58c5ca4',
11 'User3' => 'd8578edf8458ce06fbc5bb76a58c5ca4'
12 );
13 }
 

fadx

Filthy Cheater
Member
Joined
Sep 15, 2016
Messages
430
Trophies
0
XP
2,453
Country
United Kingdom
I'm really not sure, I would check the website you got that source from and see if they also have a user system that you could use to register accounts etc. I actually don't really know any PHP but I know a good bit of C# and I've worked with databases before so I was able to piece together what the source code was looking for. Unfortunately I don't really know how you'd manage user creation etc.
 

MaxiBash

Your Local Random Internet Geek
OP
Member
Joined
Jul 14, 2018
Messages
1,287
Trophies
1
Website
trashbandatcootofficial.cardd.co
XP
5,024
Country
Netherlands
Ok, guess I have to contact the Source creator

--------------------- MERGED ---------------------------

Fun fact:
The users are hardcoded, so despite finally working, I can't add more users, meaning I have to find a new PHP chat.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Psionic Roshambo @ Psionic Roshambo: https://www.youtube.com/watch?v=KYZD7ykz9aQ