Hi; I have been doing this stuff for years now, but largely "by the seat of my pants" (with much help from y'all here).
Anyway, as I am currently retired (and do not have a crush of "do this NOW by whatever means necessary" type requests/orders) I have the time to step back and wonder if I do this stuff (e.g. mysqli queries) as correctly as I ought to, or if I am being "sloppy" with respect to the overall process.
For example: For select statements I typically create a link statement, a query statement, a result statement and (often) have the resulting data dumped into a $_SESSION variable so that I can quickly display (or redisplay) the retrieved facts on my pages as the visitor moves around on the website.
The part that I am wondering about is stuff like killing or closing links and threads and stuff like that that I have seen in other people's code. I don't know much about that or how necessary it might be. If I _don't do things like that is it a burden on the server? Will my scripts tend to run less well (e.g if/when I have multiple query processes going on to serve the site visitor's interactions on my site.
So that's the question, if I am doing simple select queries against a database is there something I really OUGHT to be in the habit of doing in a script beyond these three statements?
$link=mysqli_connect("localhost", "uname", "pword", "dbname") or die (echo "Could not connect : " . mysqli_error($link));
$sql="SELECT * FROM table ORDER BY id DESC";
$result=mysqli_query($link, $sql);
while ($line=mysqli_fetch_array($result, MYSQLI_ASSOC)) {
$SESSION[blah][]=$line;
}
...from which I go on my merry way, displaying results contained in the array of data $SESSION[blah].
Am I leaving some "proper" parts of the process out that a more professional programmer would be sure to do in order to prevent potential server problems, security stuff, etc.?
)
start a new session.