how to make code in a right way not repeating?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

TJH
Forum Newbie
Posts: 2
Joined: Sat Aug 12, 2006 12:55 pm

Post by TJH »

Hi,

You can declare this only once in each file.


include "IncludeFiles/db_config.php";
$myConn=mysql_connect($host,$uname,$pword);
$mydb=mysql_select_db($dbname,$myConn);



And you can use any name for variable. just make sure to use the variable you declared.

$sql2="select * from categories";
$rs=mysql_query($sql2,$myConn);


Cheers....
Post Reply