converting a mysql entry to a text by PHP

Codes here !

Moderators: macek, egami, gesf

ayucuk
New php-forum User
New php-forum User
Posts: 2
Joined: Mon Feb 03, 2003 2:30 pm
Contact:

converting a mysql entry to a text by PHP

Postby ayucuk » Mon Feb 03, 2003 2:42 pm

i have a webpage with mysql .. it contains lyrics .. now lyrics get too big so this makes server to overload sometimes .. my friend having an idea that we can convert these mysql entries to a single txt files "Artist Name - song name".. have any script or does anybody know a way to do this ?? i only know simple PHP commands so if you can explain or write a script for me , i will be pleased ...

mysql entries like that
id Views pending_reports Track Title Artist Album Year Genre Comment Composer Orig_Artist Copyright URL Encoded_by UploadBy lyric date


so i want file names as artist - title . and this txt will contain other things like lyrics, year,album
thanks for helps...

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Tue Feb 04, 2003 12:50 am

modify this code cuts and you will get your script

//Query
SELECT * FROM `liriks`


after that loop
While ($data=mysql_fetch_array($your_query))
{
//save as file

$file=fopen ("$data[art_name] - $data[title]", "a");
fwite($file, $data['content']);
fclose($file)
}

ayucuk
New php-forum User
New php-forum User
Posts: 2
Joined: Mon Feb 03, 2003 2:30 pm
Contact:

Postby ayucuk » Tue Feb 04, 2003 3:21 am

include("connect.php");
$query = "SELECT * FROM lyrics";
While ($data=mysql_fetch_array($query))
$file=fopen ("$data[artist] - $data[title]", "a");
fwrite($file, $data['content']);
fclose($file)


did i do something wrong ??i think i do as usual
because explorer shows

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/virtual/site24/fst/home/lyrics/public_html/lyricsyb/amanfile.php on line 18

Warning: fwrite(): supplied argument is not a valid File-Handle resource in /home/virtual/site24/fst/home/lyrics/public_html/lyricsyb/amanfile.php on line 22

Warning: fclose(): supplied argument is not a valid File-Handle resource in /home/virtual/site24/fst/home/lyrics/public_html/lyricsyb/amanfile.php on line 23


line 18:While ($data=mysql_fetch_array($query))
line 22:fwrite($file, $data['content']);
line 23:fclose($file)

sorry about lack of knowledge of PHP.. but thanks for help :)

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Tue Feb 04, 2003 3:33 am



Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 2 guests

cron