Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

converting a mysql entry to a text by PHP

Codes here !

Moderators: macek, egami, gesf

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...
ayucuk
New php-forum User
New php-forum User
 
Posts: 2
Joined: Mon Feb 03, 2003 2:30 pm

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)
}
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

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 :)
ayucuk
New php-forum User
New php-forum User
 
Posts: 2
Joined: Mon Feb 03, 2003 2:30 pm

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

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


Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron