I am new to PHP and I'm trying to connect to my database, can someone help?
index.php:require_once("modules/config.php");
require_once("modules/class_session.php");
$session_class = new Sessions();
session_start();
if(isset($_SESSION['username'])) {
header('Location: modules/store.php');
}
$link = ($GLOBALS["___mysqli_ston"] = mysqli_connect(HOST, USER, PW));
if (!$link) {
die ("Error connecting to the database: " . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
}
$db_selected = ((bool)mysqli_query( $link, "USE " . constant('DB')));
if (!$db_selected) {
die ("Error selecting the database: " . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
}
>>51257004<?php
// Database constants
define("HOST", "localhost");
define("USER", "root");
define("PW", "neoben");
define("DB", "ecommerce");
// Session Class constants
define("SESSIONS", "sessions");
define("SESSIONID", "sid");
define("SESSIONDATA", "sdata");
define("SESSIONEXPIRE", "sexpire");
?>
>>51257004
You need to enter a host, username & password OP.
>>51257004
It says: "password: NO"
>>51257004
are you using pgsql as a database?
>>51257004
>user any
>host localhost
>password no
>grant no
Gee I wonder.
>>51257048
pgsql means postgresql
>>51257004
Try removing the password.
If you are using Windows 8/10, use 127.0.0.1 instead of localhost
>>51257072
>postgresql
Yes I am.
>>51257099
you are using a mysqli adaptor with a postgresql database. Google what those things mean and figure it out
>>51257113
You are an asshole.
>>51257091
THIS NIGGER IS SO USEFUL! THANK YOU. PLEASE STAY HERE AND NEVER LEAVE WITHOUT PEOPLE LIKE YOU WE WILL HAVE MORE RETARDS.
>>51257163
ok then ill be on my way
btw, thanks for compliment senpai
>>51257163
"rtfm" is a response that you will see in serious message boards. Don't be surprised.
>>51257196
>rtfm
>implying this is a 'serious message board'
stop being an elitist.
>>51257252
stop being a comsumerist