MySQL Connect
Posted: Tue Feb 04, 2003 2:51 pm
When I connect to my MySQL server I just do it like this:
The connect.php file contains:
Should I also add after each opening of the database:
And can you give me any other ways of doing this. I am looking for a more secure way of connecting so after each opening the database is closed and there is no way of getting in. Just a security question.
Thanks!
Code: Select all
<?php
include("connect.php");
$result = mysql_query("SELECT * FROM table ORDER BY id ASC");
$row = mysql_fetch_array($result);
?>Code: Select all
<?php
$link = mysql_connect("localhost", "username", "xxx") or die("Could not connect");
mysql_select_db("db_name") or die("Could not select database");
?>Code: Select all
<?php
mysql_close($link);
?>Thanks!