Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Server Side Programming > PHP Programming
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 09-18-2006, 08:43 PM
  #1
wolfdogg
Deity (Level 17)
 
wolfdogg's Avatar
 
Join Date: Jul 2005
Posts: 830
iTrader: (0)
wolfdogg is on a distinguished road
$dbc $gDbManager

$dbc $gDbManager,
are these 2 teh same function? are these common variables used for connections? or do they server 2 different purposes. currently, they are confusing me. ill include some code to see if you can help me figure out what variable i should be using.

heres my db connec in my config.php file
Code:
// database login info
define("USE_PERSISTENT_CONNECTIONS", "true");
define("DB_HOST", "localhost");
define("DB_USER", "user");
define("DB_PASSWORD", "password");
define("DB_NAME", "database_name");
define("MYSQL_CONNECTION_STRING", "mysqli://" . DB_USER . ":" .
	DB_PASSWORD . "@" . DB_HOST . "/" . DB_NAME);	//$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
will this allow me to use $dbc to connect as in
Code:
// Execute the query:
		$r = mysqli_query ($dbc, $q);
or does this line thats in cluded in the header change all that
Code:
// global DbManager instance                                 
$gDbManager = new DbManager(MYSQL_CONNECTION_STRING);   
                                                                                                                 
?>
prompting me to use DbManager instead such as
Code:
mysqli_close($gDbManager);
?

i cant figure out why both are used. they must be 2 different functionsssss.....?????

Last edited by wolfdogg : 09-18-2006 at 08:45 PM.
wolfdogg is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-18-2006, 09:03 PM
  #2
erisco
Catapulted
 
erisco's Avatar
 
Join Date: Dec 2005
Location: Within the division of zero
Posts: 5,858
iTrader: (0)
erisco will become famous soon enougherisco will become famous soon enough
$dbc is equal to this:
Code:
mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
But you need to uncomment the line.

DbManager is not a variable, it is a class (I think) that was defined also in your config file. The define() function just defines a constant, which is the exact same as a variable, except you cannot change the value, ever.
erisco is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-18-2006, 09:21 PM
  #3
wolfdogg
Deity (Level 17)
 
wolfdogg's Avatar
 
Join Date: Jul 2005
Posts: 830
iTrader: (0)
wolfdogg is on a distinguished road
not sure what line you mean to uncomment?

ahhhhhhh, ok, i see it. i think i commented that line a while back because i was having mysqli problems. thanks for noticing that.....

so,
what connection string should i use then? if i use $dbc, without creating any more variables, will it call my connection properly then? or do i have to use something else....

let me show you the exzact line that is in question. Will this following $dbc connection work ok on my existing setup assuming i uncomment that line?
Code:
// Display the expense categories:
	$r = mysqli_query ($dbc, 'SELECT * FROM vehicle_category ORDER BY vehicle_category');
	while ($row = mysqli_fetch_array ($r, MYSQLI_NUM)) {
		echo "<option value=\"$row[0]\">$row[1]</option>\n";

Last edited by wolfdogg : 09-18-2006 at 09:28 PM.
wolfdogg is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-19-2006, 04:47 PM
  #4
scoutt
Mister Admin to you
 
scoutt's Avatar
 
Join Date: Jul 2001
Posts: 30,848
iTrader: (0)
scoutt is a jewel in the roughscoutt is a jewel in the roughscoutt is a jewel in the rough
ok lets follow this through.
PHP Code:
// database login info
define("USE_PERSISTENT_CONNECTIONS""true");
define("DB_HOST""localhost");
define("DB_USER""user");
define("DB_PASSWORD""password");
define("DB_NAME""database_name");
define("MYSQL_CONNECTION_STRING""mysqli://" DB_USER ":" .
    
DB_PASSWORD "@" DB_HOST "/" DB_NAME);    
//$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); 
the reason you see two ways to connect is that on some server where php5 is installed it uses mysqli while older version of php there is mysql. now, if all depends on which one you have. it will not use both.
__________________
Have a Script or Snippet you want to share?

WWW Standards: HTML 4.01, CSS2.1, CSS3, XHTML 1.0
PHP Standards: PHP Standards
scoutt is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-19-2006, 05:22 PM
  #5
erisco
Catapulted
 
erisco's Avatar
 
Join Date: Dec 2005
Location: Within the division of zero
Posts: 5,858
iTrader: (0)
erisco will become famous soon enougherisco will become famous soon enough
I'm attentive scoutt, I really don't know what is going on with this code either.
erisco is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 09-20-2006, 02:39 PM
  #6
wolfdogg
Deity (Level 17)
 
wolfdogg's Avatar
 
Join Date: Jul 2005
Posts: 830
iTrader: (0)
wolfdogg is on a distinguished road
blame it on Darie, go to www.christiandarie.ro and you meet the author. hehe. i think i added that 2nd connection string however, and commented it out, because i wanted it there for comparison and learning. all the code is here http://www.apress.com/ApressCorporat...93928-2358.zip
wolfdogg is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart



 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 09:35 PM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.