TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,030
  • Total Topics: 21,334
  • Online today: 519
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 140
  • Total: 140

Fast question : are blocks safe enough?

Started by Heero, July 31, 2008, 07:29:47 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Heero

Well hey again,
I'm here with a fast question.
Since I want to use a script that includes my database name + password,
I'd like to know if its safe?
The script looks as followed :

$link = mysql_connect('localhost','databasename', 'password') or die('Could not connect: ' . mysql_error());
mysql_select_db('database_smf') or die('Could not select database');
$querydl = 'select * From `reps_table` order by Downloads DESC limit 0,3';
$resultdl = mysql_query($querydl) or die('Query failed: ' . mysql_error());
$querylast = 'select * From `reps_table` order by `Datum` DESC limit 0,3';
$resultlast = mysql_query($querylast) or die('Query failed: ' . mysql_error());
$queryrand = 'select * From `reps_table` ORDER BY RAND()  limit 0,3';
$resultrand = mysql_query($queryrand) or die('Query failed: ' . mysql_error());


Thanks in advance.

Ianedres

SMF provides the db_query function to interact with the database safely and securely.

G6Cad


IchBin

I don't think you'll be able to connect to another base within TP. PHP can only make a connection to one database per request. If you are using SMF's DB, then you don't need to use any of those connection functions. Just use db_query() to call query the DB as Ianedres said.

Heero


Ianedres

As a general rule for other scripts, you should 1) put your connection info into a separate script, and 2) stored in a directory off the public webserver with restricted access via your .htaccess file.

You can then include the connection script at the top of your script (and any other scripts), making for one location to store the info and avoid errors...

This website is proudly hosted on Crocweb Cloud Website Hosting.