Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Streda, 11. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  Include Database Information

phpMyEdit Configuration     Include Database Information
Odoslať novú tému   Odpovedať na tému    
 
clindsey     Založený: 01.09.2008   Príspevky: 31  
Príspevok Zaslal: 2009-02-25 04:35
Návrat hore  Odpovedať s citátom     

I am trying to use a php include to include the mysql connection information in another file for security reasons. I can't seem to get this to work, though. I've created a file, config.php, that looks like this:

Kód:
// MySQL host name, user name, password, database, and table
$opts['hn'] = 'url.com';
$opts['un'] = 'user';
$opts['pw'] = 'password';
$opts['db'] = 'dbname';
$opts['tb'] = 'table';


Then I put this code into the phpmyedit file:

Kód:
include("config.php");


I'm sure I'm missing something small, so I tried adding a forward slash to the link, and later adding php open and close markers in the include code. But still no luck.

Can anyone spot what I'm doing wrong? Thanks a bunch.

Chris

 
marrxx     Založený: 25.02.2009   Príspevky: 2  
Príspevok Zaslal: 2009-02-25 12:12
Návrat hore  Odpovedať s citátom     

clindsey Napísal:
I am trying to use a php include to include the mysql connection information in another file for security reasons. I can't seem to get this to work, though. I've created a file, config.php, that looks like this:

Kód:
// MySQL host name, user name, password, database, and table
$opts['hn'] = 'url.com';
$opts['un'] = 'user';
$opts['pw'] = 'password';
$opts['db'] = 'dbname';
$opts['tb'] = 'table';



Then I put this code into the phpmyedit file:

Kód:
include("config.php");


I'm sure I'm missing something small, so I tried adding a forward slash to the link, and later adding php open and close markers in the include code. But still no luck.

Can anyone spot what I'm doing wrong? Thanks a bunch.

Chris



// MySQL host name, user name, password, database, and table

try this:

mainfile :

include("config.php");

$opts['hn'] = $host;
$opts['un'] = $user;
$opts['pw'] = $password;
$opts['db'] = $dbname;
$opts['tb'] = $table;

and in the config.php

<?
$host="XXXXX";
$user="XXXXX";
$password="XXXXX";
$dbname="XXXXX";
$table="XXXXX";
?>

 
clindsey     Založený: 01.09.2008   Príspevky: 31  
Príspevok Zaslal: 2009-02-25 19:47
Návrat hore  Odpovedať s citátom     

This didn't work either.

 
marrxx     Založený: 25.02.2009   Príspevky: 2  
Príspevok Zaslal: 2009-02-25 23:22
Návrat hore  Odpovedať s citátom     

clindsey Napísal:
This didn't work either.


please try your way, and use
require_once 'conf.php';
in your phpmyedit script
the config.php must be in the same folder as your phpmyedit script

<? <-- important signs
// MySQL host name, user name, password, database, and table
$opts['hn'] = 'url.com';
$opts['un'] = 'user';
$opts['pw'] = 'password';
$opts['db'] = 'dbname';
$opts['tb'] = 'table';
?> <-- important signs

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2009-02-28 07:26
Návrat hore  Odpovedať s citátom     

Kód:
<?php

// Maybe short tags are OFF in the server's php.ini file
// Short tags are a bad idea, OFF on most web hosts

?>


 
clindsey     Založený: 01.09.2008   Príspevky: 31  
Príspevok Zaslal: 2009-03-11 22:19
Návrat hore  Odpovedať s citátom     

Marxx,

That did it. Thanks so much.

To the forum administrators, this would be helpful information to include in the documentation (which currently just vaguely mentions using php includes for security).

Chris

 
doug     Založený: 10.02.2003   Príspevky: 1013   Bydlisko: Denver, Colorado (USA)
Príspevok Zaslal: 2009-03-14 17:21
Návrat hore  Odpovedať s citátom     

A bit late to think of this, but I the class file probably closes the database connection. If you need the connection in order to run a custom MySQL query in the page footer, then you need to comment out the db closure in the class file.

 
clickbr     Založený: 30.03.2011   Príspevky: 4  
Príspevok Zaslal: 2011-04-12 20:12
Návrat hore  Odpovedať s citátom     

whats save file com fopen?
@fopen('/home/user/public_html/db.php', 'w+');

marrxx Napísal:
clindsey Napísal:
I am trying to use a php include to include the mysql connection information in another file for security reasons. I can't seem to get this to work, though. I've created a file, config.php, that looks like this:

Kód:
// MySQL host name, user name, password, database, and table
$opts['hn'] = 'url.com';
$opts['un'] = 'user';
$opts['pw'] = 'password';
$opts['db'] = 'dbname';
$opts['tb'] = 'table';



Then I put this code into the phpmyedit file:

Kód:
include("config.php");


I'm sure I'm missing something small, so I tried adding a forward slash to the link, and later adding php open and close markers in the include code. But still no luck.

Can anyone spot what I'm doing wrong? Thanks a bunch.

Chris



// MySQL host name, user name, password, database, and table

try this:

mainfile :

include("config.php");

$opts['hn'] = $host;
$opts['un'] = $user;
$opts['pw'] = $password;
$opts['db'] = $dbname;
$opts['tb'] = $table;

and in the config.php

<?
$host="XXXXX";
$user="XXXXX";
$password="XXXXX";
$dbname="XXXXX";
$table="XXXXX";
?>


 
clickbr     Založený: 30.03.2011   Príspevky: 4  
Príspevok Zaslal: 2011-04-12 20:14
Návrat hore  Odpovedať s citátom     

whats save file com fopen?
@fopen('/home/user/public_html/db.php', 'w+');


===
marrxx Napísal:
clindsey Napísal:
I am trying to use a php include to include the mysql connection information in another file for security reasons. I can't seem to get this to work, though. I've created a file, config.php, that looks like this:

Kód:
// MySQL host name, user name, password, database, and table
$opts['hn'] = 'url.com';
$opts['un'] = 'user';
$opts['pw'] = 'password';
$opts['db'] = 'dbname';
$opts['tb'] = 'table';



Then I put this code into the phpmyedit file:

Kód:
include("config.php");


I'm sure I'm missing something small, so I tried adding a forward slash to the link, and later adding php open and close markers in the include code. But still no luck.

Can anyone spot what I'm doing wrong? Thanks a bunch.

Chris



// MySQL host name, user name, password, database, and table

try this:

mainfile :

include("config.php");

$opts['hn'] = $host;
$opts['un'] = $user;
$opts['pw'] = $password;
$opts['db'] = $dbname;
$opts['tb'] = $table;

and in the config.php

<?
$host="XXXXX";
$user="XXXXX";
$password="XXXXX";
$dbname="XXXXX";
$table="XXXXX";
?>


 
Odoslať novú tému   Odpovedať na tému    

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov