Database questions,

Started by eliteghost, August 18, 2008, 03:51:50 PM

Previous topic - Next topic

eliteghost

Im going to use my database on my website, Ive added fields onto the memberID table in phpmyadmin,

Can you please give me example script on how I would load the database on my website,  like how to require/ include it.  and a few other how to script.

  • How to read from database specific feild,  (where does my new feild name come in script?)
  • How to write to the database
  • How to print a database feild
  • How to Open, close the database?
  • Is it secure to use the database outside my forum?
  • Is there anything else i need to know, if im using the database outside the forum?

Thanks,

ryanx5452

Pretty much look here,  http://www.w3schools.com/php/php_mysql_connect.asp
I read through the MySQL stuff and was up and going quickly.

eliteghost

yeah but how safe is that, if im using source code from my website,  the first line is mysqul connect(username,password,)


wont any idiot be able to right click view soruce and see that?

ryanx5452

you can create a seprate file, called whatever "passcodes" I dont know, then include it.  in it put variables like


<?php

// These are variables to use in your sql query

$dbhost = 'localhost';
$dbuser = 'username';
$dbpass = 'password';
$dbname = 'nameOfDatabase';
?>


then you include it and use it,



<?php
include('passcodes.php');

$con = mysql_connect($dbhost, $dbuser,$dbpass);

?>


eliteghost


[SiNaN]

You can just include SSI.php and use $db_prefix in your queries.
Former SMF Core Developer | My Mods | SimplePortal

Advertisement: