+ 2
Am developing a chatbox its almost done but i need a php connection code. Any help is appreciated, am using HTML and Javascript
8 Answers
+ 2
So your after a simple database connection right? I would suggest looking at PDO for best practices but if that seems a little confusing you could always use the below and include it on the same page as your SQL statements.
<?php
$host="XXX";
$username="XXX";
$password="XXX";
$db_name="XXX";
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
?>
+ 1
So are you using MYSQL to store the messages or are you storing it locally using javascript?
+ 1
mysql
+ 1
Hi, I think mysql got depreciated. Give the syntax for the mysqli or MariaDB
+ 1
Your correct, mysql is depreciated and i would always advise using PDO with mysqli instead. Just couldn't be bothered to write one out lol.
@Edward, i will write a simple easy to understand snippet of code for you later this evening, just getting a tad busy at work.
0
Ok thanks.
0
Hmm, I have an Backend API for MVC written on PHP, but I don't know if it'll work for you as it worked for me.
- 1
my question is how to get messages displayed after i load to the website