[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
I am new to PHP and I'm trying to connect to my database,
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 16
Thread images: 1
File: test.png (28 KB, 567x266) Image search: [Google]
test.png
28 KB, 567x266
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
Thread replies: 16
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.