FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


INCLUDE(FILENAME) -------





cLean
Got major problem I MUST be albe to do this i do not like the idea of leaving my user pw etc.. on my main page.. i want it to include or require the file i need i have tried these methodds.. Read carefully once i get to the CONFIG part that holds my DATABASE INFO I need some help on setting my attributes ok soo ive tried this

Code:
  include('scripts/mainmenu.php');      --------------][][][][][][]][][][----------- 
                   include($_SERVER["DOCUMENT_ROOT"]."/scripts/mainmenu.php");



Now i have my pass to my DB IP USER DATABASE name Etc.. in a file under a folder /config/filename.php

if someone can give me the attribute number i should use so no one in public can see it and and only the server and launch it when its embedded in a site. ( if u understand that part) im sure u do. most people do this

--------------------][][][]]]][][][][][]][][][][ ----------------
Manofgames
666 / 775 Should do it
Its better to say 'What should I CHMOD my files to make sure no one can access them'

A good thing to do, is to put this in your main file (the one the user will visit when they go on your site (i.e. index.php):
Code:

define('IN_SITE', true);

Then in your database config page, put this:
Code:

defined('IN_SITE') or exit('Access to ' . basename(__file__) . ' Is not allowed');

If the db pass script is not loaded by a page of your site, it will stop executing the script.
cLean
i still cant get it to find my database..... wtf???
cLean
this is giving me so many problems... can i get a test setup... from someone that does this to save there usernames passes and db names... it would be greatly appreciated and i can help you in someway also.!!!


1. * include file *

2. * the query and select db etc... findn and selectin the table. , *

3. * and a copy of the config_db.php file if cld.. *

Thanks alot

Anything i can do in return spit it ill do it.!

I dont know why this dont work im doing it correct..BELOW is mINE

Code:

// INCLUDE FILE;
include($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");

// COnnect to mysql server;
$dbctx = @mysql_connect('$db_host', '$db_user', '$db_password);
if (!dbctx) {
exit('<p>Unable to Connect to the ' .
'database server a this time. or die(mysql_error())</p>');
}

//locate database;
if (!@mysql_select_db('$db_name')) {
exit('<p>Unable to locate Frag-Nations ' .
'database at this time. or die (mysql_error())</p>'); }
?>

-=-=-=-=-=-=-=-=-= *           db_config.php FILE        * -=-=-=-=-=-=-=-=-=-=

<?php

$db_host = localhost;
$db_user = myuser;
$db_password = mypass;
$db_name = mydb;
?>



OR this maybe ??? if this wont work.. b/c of the excess.. tell me.  B?C i have it on the CONNECT TO DB, AND THE SELECT DB


<?php

$db_host = localhost or die(mysql_error());
$db_user = myuser or die(mysql_error());
$db_password = mypass or die(mysql_error());
$db_name = mydb or die(mysql_error());
?>

telll me wut u think


Thanks for anything

my msn is jeremy_massey@hotmail.com ondesktop (GAMING COMP) or my labbie MAIN US E ( SCRIPTING, GFX AND JUST OL DESIGN) ---- l.p.b.t@hotmail.com
Manofgames
Code:

// INCLUDE FILE;
include($_SERVER["DOCUMENT_ROOT"]."/config/db_config.php");

// COnnect to mysql server;
$dbctx = @mysql_connect($db_host, $db_user, $db_password);
if (!dbctx) {
exit('<p>Unable to Connect to the database server a this time<br/>' . mysql_error());
}

//locate database;
if (!@mysql_select_db($db_name)) {
exit('<p>Unable to locate Frag-Nations database at this time<br/>' . mysql_error());
}
?>

-=-=-=-=-=-=-=-=-= *           db_config.php FILE        * -=-=-=-=-=-=-=-=-=-=

<?php

$db_host = 'localhost';
$db_user = 'myuser';
$db_password = 'mypass';
$db_name = 'mydb';
?>


Code:

$dbctx = @mysql_connect('$db_host', '$db_user', '$db_password);

Will try and connet to the database server $db_host (I mean litterally $db_host), with the username $db_user, and the pass $db_pass.
[code]
' '
[/code
Quote marks will create a literal string.
Speech marks will create a parseable string (by parseable, I mean that php will parse it for variable names)
You also didn't have quote or speech marks around your host, user name, pass or db name, which is going to cause trouble.

And to top it all off, you had a call to die() within a call to exit(), which is one of the craziest things I've ever seen Shocked

Anyway, happy coding Very Happy
cLean
ITS STILL saaayin bad pw... and thheeerreeefoooorrr cant locate db.!!
Manofgames
Add
Code:

echo 'This has been included';

to the end of db_config.php, just to see if its being included.
Do you really need $_SERVER["DOCUMENT_ROOT"] ?
cLean
finally got it, well finally had about 30 mins to try differnt things... things for all the help guys... somthing so simple was yet so hard lol... it was somthing i set as a var that made it, have problems..
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.