Jump to content

[SOLVED] Mysql questions


alecks

Recommended Posts

I was wondering:

 

If I've only got one database that I need to use, would it be better to simply mysql_connect at the beginning of the script and stay connected until the end, or connect each time I need to query?

 

I was doing it the latter way, here is the function that I was using...

 

function basic_query($query){
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$result = mysql_query($query) or die(mysql_error());
mysql_close();
return $result;
}

 

The returned $result could then be used in a fetch array loop, etc... Is there a better way to do this?

Link to comment
https://forums.phpfreaks.com/topic/75005-solved-mysql-questions/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.