Jump to content

MySQL Database/Variables


Phyco1312

Recommended Posts

Quick question for people out there. I'm more of a script kiddie than I am a database programmer, but I know my share of MySQL coding. Here's my question:

 

 

 

 

 

 

 

If I create the table in database "theftus1_fire", how would I define and bring up a variable on a php page without comprimising the database username, and password? I'm trying to make my website completely MySQL and I want to be able to insert data into the MySQL database/table and have it brought up on the website without typing it out into HTML (HTML text, etc.)

 

 

 

 

 

 

 

Thanks to whoever looks into this.

Link to comment
Share on other sites

You'll have to type the username into plain text but if you do it in a PHP file there's less security risk since PHP isn't viewable like HTML.

 

 

 

 

 

 

 




//config.php



<?php



   $user      = 'username';



   $pass      = 'password';



   $db         = 'database_name';



   $table      = 'table_name';



   $server    = 'localhost';



?>

 

 

 

 

 

 

 

 

 

 

 

<?php



   include('config.php');



   mysql_connect($server,$user,$pass) or die('Make sure your server, username and password are correct.');



   //rest of code here



 

 

 

 

 

 

 

That should be sufficient.

 

 

 

 

 

 

 

mysql_select_db($db);

Link to comment
Share on other sites




echo $row['variable'];



 

 

 

 

 

 

 

that should work

 

 

 

 

 

 

 

Assuming of course that $row is a valid reference to a row in the table ;)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.