Question:
php help, database?
kien
2007-06-06 09:33:02 UTC
Whats missing in these code below? please shows me whats MISSING only, I do NOT need new code. Thanks for help.

class db
{
function connect ()
{
global $g;
global $DB_conn;
global $DB_res;
global $DB_debug;
global $DB_timer;
global $DB_sqls;
$host = $g['db']['host'];
$db = $g['db']['db'];
$user = $g['db']['user'];
$pass = $g['db']['password'];
if ($DB_debug)
{
$DB_timer = $DB_timer + time () + microtime ();
}

$DB_conn = mysql_connect ($host, $user, $pass);
if (!($DB_conn))
{
trigger_error ('Can\'t connect to MySql: ' . mysql_error ());
}

thanks
Three answers:
Brandon F
2007-06-06 09:44:51 UTC
1 - I don't see a constructor.

2 - Neither the class nor the connect() function has their closing brackets.

3 - Unless trigger_error() is defined elsewhere, it's an invalid function.

4 - You don't want to use global variables for database objects because other functions could overwrite them. You need to create a singleton to handle your database access for each database, otherwise you're risking major data integrity issues.
?
2016-11-27 00:30:10 UTC
you could set up a database on your shopper computing device in case you desire. you may have hardship installation a Hypertext Preprocessor database. i think of you're pertaining to MySQL. you have a *lot* of interpreting to do in the previous you even evaluate doing what you have planned, in case you ask one in each of those question. Google "working a server from homestead" or some thing comparable.
Drew W
2007-06-06 09:36:36 UTC
well for one trigger_error is not a valid php function...


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...