You are here: using global variables in the database connection string « PHP Programming Language « IT news, forums, messages
using global variables in the database connection string

Posted by frothpoker on 06/20/06 11:30

Guys,

I'm sure this has been asked a million times but I can't seem to
formulate a google search that returns what i'm looking for.

I've go a dev and live environment. Currently the DB connect string is
hard coded into each php file which means i'm going to have to change
every page - Arrgh!!

If i put the DBonnect into a function and store it in an include file,
it doesn't seem to work, Also the connetion works with inline PHP
statements, but I have to repeat it in every function even if they are
in the main php file??? which doesn't seem right to me..

I need to either :-

Store the connection variables in an include file and retrieve them as
global values

OR

Store the connection string in a function in an include file which can
be accessed by all functions.

also do I really have to call the dbconnect inside every function.

Please note, if it makes any difference, I still havn't got my head
round OO programming in PHP so it is still pretty much procedural. I
am using PEAR but dont really understand (or care at the moment) about
what it is doing.

Thanks in advance

Aaron

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация