Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Best Way To Set DB Connection Settings


I was wondering what is the best way to code the DB connection settings, by settings I mean the username/password and DB name. Right now I'm doing it in every php file that talks to the MySQL DB, but I think it may not be a good idea. How do you guys do it? like call it from a central file or something?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Settings
How would I get a setting from mysql using this $settings['title']

Permission Settings
I'm having some problems with file permissions, is there a way to set it so i can write to the file, then after it writes set it back so it can't, so that i can make sure everything is secure.

here is some code i'm using now.

===================================

if (!isset($HTTP_GET_VARS["filename"]) && !isset($HTTP_POST_VARS["filename"]))
echo("No such luck - no file to edit.");
else
{
if (isset($HTTP_POST_VARS["submit"]))
{
$fn = stripslashes($HTTP_POST_VARS["filename"]);
switch ($HTTP_POST_VARS["submit"])
{
case ("Save"):
{
$fh = fopen($fn, "w");
$fcontents = stripslashes($HTTP_POST_VARS["filebody"]);
$succ = fputs($fh, $fcontents);
fclose($fh);
}
break;
case ("Delete"):
{
if (unlink($fn))
die("<p>" . $fn . " has been vaporized.</p></body></html>");
else
die("<p>" . $fn . " has escaped vaporization.</p></body></html>");
}
}
}
else
{
$fn = stripslashes($HTTP_GET_VARS["filename"]);
$fcontents = join ('', file($fn));
}

======================

Display Settings
I am trying to have a page open up in both netscape and ie which will simulate having the display settings on the p.c. set as a desktop area of 800x600 pixels. Has anyone done anything like this with php? I was looking at the javascript window.open syntax but was wondering about php.

Php Session Settings
I have tried using the following CMS systems on my web server (remote)
Joomla
CMS made simple
Phpwebsite
And more recently
Coppermine photo album
All of these apps use PHP heavily.
None of these apps seem to run very well and they all require constantly...

PHP Server Settings
PHP seems great but I don't think my server is set up properly for it. It's a RAQ4 with PHP4 installed, apparently (Webfusion/Dedicated Servers special). When I open a file ending in .php that is on my server, within a browser , it wants to download it, not show it.

Session Settings In Php.ini
I may have some misundertanding /lack of information, but I have always
wondered this:

Why there must be THREE setup lines concernig cookie/transid thing:

session.use_cookies
session.use_only_cookies
session.use_trans_id

That makes 2*2*2= 6 combinations. Since this is the case, one would suppose
all 6 are meaningful and sensible.

But why I feel that session business should in practise use EITHER cookies
OR trans_id? Not both at the same time and not anything(what) else also. In
that case only one line was enough and ANYWAY, one line would eliminate
impossible combinations.

why have not like: session_policy = "cookies" // options: 'cookies',
'trans_id', 'both'

What is it that I don't get? What is it that I have misunderstood? Or is
there some historical reasons. Please, list your opinion of MEANINFUL
combinations of those three settings. Thanks for answers, I believe this can
enlighten others too.

Getting File And Dir As Settings
I need to create a small settings window in PHP.

I need to set options like
1) an exe file
2) directories (search path), one by one, output
3) allowed users for certain items (string list)

I found this:
<input type="file" name="file" size="20" <? print("value=$mergerprg2");
?>>

but I cannot set the present file here - how do I do that?

how do I select a directory?

.htaccess Settings
I read in a PHP and MySql book that you can set auto_prepend_file into a .htaccess file in a directory on an Apache server and set up headers and footers for all files in that diretory. I gave this a try.

Code for .htaccess:
line 1- php_value auto_prepend_file "/footer.inc"
Code in footer.inc:
<center><a HREF= "javascript:window.close();">Close Window</a></center>

I am getting an Internal Server error whenever I try and open a file in the directory. I remove the .htaccess file and refresh and the page opens just fine.

Question To Php-settings
i have some php-scripts with things like this

echo <snip> _("Name:") ; <snap>

it is not possible to see this page in my browser

when I change this in

echo <snip> ("Name:") ; <snip>

the page is loaded.

I think it's an php-setting, but which ?

Server Settings For File I/O
I have a script which basically just does this PHP Code:

How To Change Settings For Cron Job.
Hello I have VPS. I have made an account in it and its working fine. But only one thing is that when i try to set a cron job via cpanel.I m sure the path to file is Ok e.g /home/username/next-path to file. But When this cron runs there comes the msg in email that permission denied. How can i solve this prob. The file permissions are 744. Is i am to allow this feature from WHM. if yes then how?

How To Change Configuration Settings Without Using Php.ini
How to change configuration settings without using php.ini I want to change
upload_max_filesize at runtime. By using ini_set() it is changed temporary or
permanently.

1) I want to change permanently at runtime it is possible or not.

2) I want to upload file with 100mb. What are the configuration settings are changed in php.ini file.

3) I don’t want to display warnings in the browser. How to restrict it.

Browser Settings With Cookies
i am setting a cookie with my browser but it doesnt set it if i have my browser set on medium privacy. how come my website is so harmful and wont set cookies without setting my browser to low privacy. most browsers are set to medium so is there a workaround?

Php.ini Settings Not Taking Effect
I just put up php.ini-recommended as php.ini in the server-side working directory where my php scripts are located. The file has "magic_quotes_gpc" set to "Off", but when I test it within my php script using "get_magic_quotes_gpc()" I find it is set to "On". I thought all I had to do was setup php.ini the way I wanted it and locate it in the working directory. As it turned out, I didn't have to make any changes to php.ini, just renamed it from php.ini-recommended.

Checking Browser's Settings
i was wondering if its possible to check a user's browser settings. like checking if the meta refresh or javascript or cookies are enabled. is that possible using php(or maybe javascript)?

Override Session Settings From Php.ini
running php 4.0.4pl1 on NT, i've developed a session_set_save_handler that stores the session info in a mySQL table. however, i've run into two problems, 1. one server this script is going on, i do not have access to the php.ini file 2. there's some session variables that i'd like to determine per php script (eg: session.save_path = c:/temp1 for one page and c:/temp2 for another, etc.

i'm not so worried about problem #2. i'm really looking to be able to override some of the session preferences on the server to which i have no access to the php.ini file (i need to set session.save_handler = user to get my handler to work). i've been scouring php.net/manual but haven't gotten a clear answer.

Is $Settings['string'] An Example Of An Array?
I'm still pretty new to PHP and I have a question. I know that
variables are preceeded by a "$" (dollar sign). Typically, a variable has
one value, unless it is an array. Then it is essentially a pointer to
numerous values sequential in memory. The code I'm looking at now is using
the same variable name, but assigning a different "index" to it, if you
will.

For example, I see the following:

$settings['use_default_images']
$settings['doctype']
$settings['theme_url']

And many more.

What is this feature called in PHP? I looked at the reference on php.net
and it isn't anywhere to be found under arrays.

CHMOD Security Settings
I have a webpage that some hacker managed to load a file onto. My website's help support suggested that I should not use chmod 0777 since it is not secure. However, I need to allow my site's visitors to open files & write information to them.

My question: Is there a setting that will allow site members to create, open, write to, and delete files using my pages but will not allow them to create their own pages outside of my control?

Possible To Override Php.ini Settings In A Particular Subdir?
I am working for a client who has some production sites on the machine i'm developing on. he's got display_errors turned off in php.ini for the overall web server setting. Is there some way I can over ride this setting but *only* for the subdirectory i'm developing in?

I know how to set error reporting to e_all but this doesn't help if there's a syntax error in the file I'm working on - the server just shows a blank page and I have no idea which line the syntax error is on.

Determining Session Settings In Code
I've been having problems under IE6 with a script that uses cookies, so thought I'd try switching to using sessions instead.
However, while the script works perfectly well on my own site, it doesn't always work on sites where I can't control the session settings in php.ini. I've searched through the manual, and searched previous threads here on the forum, all without success.
Is there any way, through code, that I can tell if php was compiled with the --enable-trans-sid switch, or if session.use_cookies is enabled, or all the myriad other sessions settings?

PHP Security Settings Exec ('chdir ..')
I have following question. I use exec ('chdir ..'). But in my own computer it says what it's disabled due to security reasons. in a php ini i found a string security = on, i change it to off, but nothing happens.

I use Linux OS. May be somebody can help me to enable exec command.

Call Proxy Settings From A Php Script
Is it possible to use proxy settings in a php script? How can I code this?

Php Email Attachment, Chmod Settings
I have a php script from Obie (link at bottom) which uploads a file to
the web server, then attaches it to an email, and sends it to a default
recipient.

This program requires setting a directory for the files to reside in
temporarily. What settings should I put this folder to to be most
secure, 755? 750? other? If the user is uploading, is that the
"world" permissions, or is that the "group" or "owner" permissions?
I'm not entirely sure how the upload in this script works, but it uses
the "open()" "fopen()" and "fread()" functions in there.

Php/Apache Settings, Fsockopen Not Working?
I am having problems on my websites with certain things not working. My one site will not grab rss feeds, and the other wont report external torrent information. I thought it night be the allow_url_fopen in php.ini, but it was set to On.

What other options could be affecting this? I am running slackware 11, PHP 4.4.4, MYSQL 5.0.24a, apache-1.3.37-i486-2

CHMOD Settings For PHP Image Upload
Does anyone know of a way to get past the CHMOD 777 when creating a php image upload? My new host doesnt allow CHMOD 777 and when i attempt to upload a file i get an error saying i dont have permission.

Include Files Folder - CHMOD Settings?
Currently, I have various php files in my "public" folder on my webserver. I also have "include" php files in a designated folder w/in my "public" folder (i used include("file")

Example: path files

public folder => index.php, products.php, aboutus.php, etc
public folder/include folder => includefile1.php, includefile2.php, etc

what CHMOD settings should i set... so that users cannot directly open my "include" files? and where do i set them? on the "include" folder? on the individual "include" files?

Missing Charset Or Bung Server Settings?
I was wondering if some one could take a look at the two
example server outputs below, and help me understand what is wrong.
I'm getting garbled characters.

The php script I'm developing delivers XML to a client side
application I'm also putting together in VB.NET .. Example 1 is my
development PC.. It has a recent build of PDP & Apache. This output is
good.

Example 2 is the production server and is adding all sorts of strange
characters, that are causing the XML to be invalid.

I'm thinking it has somthing to do with the lack of charset in Ex2..
perhaps. If that is the case can I specify it in the .htaccess file
because I dont have direct control over the production server. Has any
one seen this before?

Server And Document Root Settings In Apache
I'm not sure if I'm even asking the right question, but my website (not hosted by me) used codes like include $_SERVER["DOCUMENT_ROOT"] . "/include/header.php";.  Per a forum member's suggestion, I ran an echo on that command, and it gives a folder tree three folders deep...  So, online, it points to the correct page, but I'm trying to set up Apache (I used WAMP) to get a beta test site on my own computer.  So, the above command doesn't work. 

I ran searches for "document_root" and "php5/pear" (a directory in the error messages I get) to see if I could find a path setting in either Apache or PHP config files with no success. Does anyone know how to set up either my Apache or PHP config so I can define what $_SERVER and DOCUMENT_ROOT are pointing to when they're on my localhost without making them not work when I upload them to my web host?

Replaceing A Value Within An External Settings Text File.
im in the process of creating a method to allow the user to change the config file currently in use. i have created an html form with a dropdown menu, which passes the filename of the new config file forward to the action page. Code:

Checking CHMOD Settings Of A Certain File/directory
I know how to set the CHMOD for a file, but does a function exsists where I can see a file's CHMOD settings?

DB Connection Handling - I Get "too Many Connection" - What's The Solution?
I have a php-webpage that needs the database in the beginning and in
the end of the script. In the middle there is a lot of processing that
takes several seconds - during that time I don't use the database
connection.

What is the best approach? Should I close the connection after I'm
done with it OR should I reuse the connection thru my whole script?

Where can I read more about this? Any pointers?

Today I'm using the same connection thru my script. And sometimes I
get an error from the database "too many connections". What does that
mean? My webserver provider says that I have at least 100 connections
to play with. How come I get this error?

Sessions Troubles: Session.save_path Settings (Warning: Open)
Anyway I have a an Apache server installed through PHP Triad on my computer. I have had this problem before also but I always got another way around it with stuff like cookies or something.

But this time I tried running Burning Board(woltlab.de) on my comp. and I canm't get around it. What's wrong here is that the sessions.save_path isn't properly set from the begining. I get these errors while I'm running Burning Board:

This comes right at the top pf the page:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Warning: open(tmpsess_727f9c3ebeef44aa7c08ccf164e15614, O_RDWR) failed: m (2) in C:apachehtdocsb\_functions.php on line 22
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
And these 2 came below the page:
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Warning: open(tmpsess_727f9c3ebeef44aa7c08ccf164e15614, O_RDWR) failed: m (2) in Unknown on line 0

Warning: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (tmp) in Unknown on line 0
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Settings Up Additional 'http://localhosts' (ie. Localhost2, Localhost3) In Apache
My knowledge of apache is nothing impressive,. I purely use it to run
local websites. I was wondering however, if it is possible to create
more local domains like localhost. I like my local websites to be able
to run in a simulated environment as my remote host. This would maybe
run like http://localhost, http://localhost2, http://localhost3 ...

Can it be done? Btw, Im running apache on Windows.

What Are Normal Ways To Scale Up PHP's Default Settings For Growing Traffic?
PHP comes with certain defaults, set in php.ini. Among these, scripts
time out after 60 seconds, I think. The default memory limit for a
script is, I believe, 8 megs.

I assume that when people do large-scale sites with PHP they scale
these numbers up. If you have a content management system running every
aspect of a large corporate web site, including a database back end
that employees use for important, secret, protected information, then I
imagine there is quite a lot of processing that might be needed for
every request.

A limit that I run into all the time is the memory limit. If I get a
large amount of info back from the database, and then try to store the
return in an array, it is easy to go over the default 8 meg limit.

Raw SSL Connection
I need to send (not post, just send) some string to an SSL server. This is nog a SSL enabled webserver, but a pure SSL-server wich doensn't understand HTTP. Therefor I think I need to make a SSL socket connection and fwrite() the string to the socket. The SSL-server performs certificate authorisation, so I need to send my certificate and private key with the string.
As far as I understand, PHP can't to this so I need to perform the ssl handshake myself with some openssl functions, then ssl encrypt the string with another openssl function, send it to the socket... read the response, decrypt it, and process this further?

Does anyone have a clue how to do this?
cURL is not an option since cURL, as far as I know, only talks HTTP over a wide range of protocols.

I've been messing with 'openssl s_client' but after the SSL handshaking completes the connection is closed and I am unable to send a message.

Php Sql Connection
i get this error when trying to use php to add something into the database, i thought Php wasnt compiled correctly but i am using phpMyAdmin so surely that uses mysql_connect!! and that works fine. I am using a cobalt raq4 if that has anything to do with it!
Error i get!

Fatal error: Call to undefined function: mysql_connect() in /home/sites/site20/web/vb/confadd.php on line 2 Code:

<?php
mysql_connect ('localhost','username','password');
mysql_select_db ('database');
$result=mysql_query("INSERT INTO table (accesscode,referee,username,password) VALUES ('$accesscode','$referee','$newuser','$password')");
echo ("User has been added");?>

Which Connection Is Best?
I started with php and mysql and i discovered three methods for connecting
to a database:


$conn="DRIVER={MySQL ODBC 3.51 DRIVER};SERVER=10.0.0.181;DATABASE=reserv";
$connect=odbc_connect($conn,'root','pw');

include('/inetpub/wwwroot/resphpaccess/adodb/adodb.inc.php');
$db = &ADONewConnection('mysql');
$db->Connect('localhost', 'root', 'pw', 'reserv');

$link = mysql_connect("localhost", "mysql_user", "mysql_password")
or die("Impossible de se connecter : " . mysql_error());


Which one is the best and why?
What are the pro/contras for each?

Connection To An Outside Db
Can we connect to a database(mySQL) using php, on another site. IE:  siteOne.co.uk runs some script that can connect to siteTwo.co.uk mysql database, therefore looking as its got is own etc? Any ideas or a straight NO.

I did mention about running a php to xml page that reads the db and converts it to an xml page and then it can get the data from there with absolute path etc ?

Database Connection ?
I am very new to PHP...Can i get the starting code for connecting to database....how to open the connection...what is the connectionstring ?

Oracle Connection
I am running a PHP script on unix. I am trying to connect to Oracle database. Before i start using the functions like Ora_Logon etc, what steps do i have to take in order to make PHP talk to Oracle database?

Microsoft SQL Connection
I am looking to have a php page that will have a required include of a
config file with the MS SQL connection creation. I want to have a form
that saves into a MS SQL database. Could call out to a stored
procedure or have inline code in the php page.

Anyone have examples or generic sample code I can use?

I Need A Universal Connection
I am interested in developing a web application to which I can attach any of db
like mysql,access,sql server,oracle ... as it is there in most of projects where during the installation we select any of optional db.

how to write such a code which can work with all of databases.

Db Connection Issues
The pages I have are template driven and they seem to work until I try and connect to the MySql db - then the pages don't want to display properly. I am sure it is some error in the way I am coding it. code:

Connection Errors ?
host -{ The server }- is blocked because of many connection errors. Unblock with 'mysqladmin flush-hosts'

anyone know why this message show up allot of times and goes away only after restarting mysql and apache ? is there a other way if fixing this ?

Authorize.net AIM Connection
Has anyone else connected using the AIM method yet? Code snippets would help me see the error of my ways.

SQL Anywhere 5.5 Odbc Connection
Is possible connect to database SQL Anywhere 5.5 started by
rtdsk50.exe from php using odbc?

I have error : Unable to connect to database server: unable to start
database engine, SQL state 08001.

I can connect to database using the same data source from MS Access.

Remote DSN Connection
I am trying to set up a website to connect to an SQL Anywhere database located on a remote machine.

The webserver is located on a linux server, while the database is running on a windows machine on the local network.

How can I connect to this remote database, and what ports will I have to enable access to through the firewall?

Connection Pooling In PHP?
Is that when using pconnect to mysql, it is already mean connection
pooling?

Open Db Connection
I'm trying to close unnecessary db connection to reduce the concurrent
connection. Is there any way I can find the open connection?


Copyright © 2005-08 www.BigResource.com, All rights reserved