Forum Moderators: coopster
artist varchar(100)
album varchar(100)
song varchar(100)
lyrics text
Last week I was on abroad. When I returned to home and check my site I have seen that there were problems while retrieving data from that `lyrics` table. Then I checked the database with phpMyAdmin and i have seen that table is marked as "In use". After that I tried to repair the table and it worked. My site again started to work as it should. Everything was ok till this morning. When I tried to open my site again, there was that same error in my site. I again checked my database with phpMyAdmin, this time there was not that "In use" message but when I used the "Check Table" feature of phpMyAdmin it gave me an error report about table size. I can't remember the exact error but it was saying that the table isn't at the size that it must be. Anyway, I again repaired my the table and everything seems ok now.
The PHP script is completely written by me and I am not an advance PHP+MySQL programmer. I thought that something wrong with my coding. By the way I have been running this site for about 5 months, and for the last month my visitors increased very much (about 10-15X times greater then before).
In my php pages, whenever I need to access DB I use following function connect:
function con2db () {
$dbhost='localhost';
$dbuser='username';
$dbpass='password';
$dbname='dblyrics';
$connection = @mysql_connect($dbhost, $dbuser, $dbpass) or die ("Error: Couldn't connect to DB!");
$db = @mysql_select_db($dbname, $connection) or die ("Error: Couldn't select to DB!");
}
Then I use these type of statements to get recordset:
con2db();
$rs = mysql_query("Select * From lyrics");
Then I am doing my job(getting data, printing them to output, bla bla...). But I have noticed that I am not using anything to close neither that recordset ($rs) nor the connection. This must be the porblem. Am I right or what do you advice?
P.S: Sorry for my English and thanks for reading until here.