+ 1
Php error
I copied this code online to create a forum, but when I run the code on my browser. Instead of connecting and selecting a database. It shows "cannot connect to db". Please how can I fix it. Here's the code : https://code.sololearn.com/wbHnAH4DjgOo/?ref=app
12 Answers
+ 1
are you running a local mysql server?
+ 1
by "running the code on my browser" did you mean you were running it on a web server on the internet or locally on your computer?
+ 1
did you create the database and the table?
+ 1
could be a wrong password/username or database name.
+ 1
No I checked multiple times
I think it's the script
+ 1
I am out of suggestions sorry , check their forums https://www.000webhost.com/forum/t/how-to-connect-to-database-using-php/42093
+ 1
It connects, but I think it can't the line mysqli_select_db is the problem
+ 1
Connection:
$mysqli = new mysqli("DatabaseServerName", "UserName", "Password", "DatabaseName");
All above mentioned data you can get from service provider or set yourself.
+ 1
Ep Ap Wuq
0
No, I am using 000webhost's database
0
On a web server
0
Yes