helo
I have 2 question about efficiency of code:
1. in my codes I have a file that responsible to the mysql connection which I always include in every file that I want to connect the database in.
this is the file:
now, in every page that I have mysql queries, I do the queries like this:Code:$mysql_link=mysql_connect('xxxxxxx','xxxx','*******') or die("ERROR: cannot connect to MySQL server."); if (!mysql_select_db(xxxxx',$mysql_link)) echo "Could not select the DB.";
is this ok?Code:$result=mysql_query("SELECT * FROM xxxx WHERE xxxx='$xxx' ORDER BY xxxx");
or should I do the queries like this:
Code:$result=mysql_query("SELECT * FROM xxxxxxx WHERE xxxx='$xxx' ORDER BY xxxxx",$mysql_link);
2. should I close the connection to the mysql in every page? because now I dont close it and its working fine...
but maybe its not good to the server?
Yair




Reply With Quote