|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
very complicated ASP+PHP+SQL
consider a server and a database named xilviu. into this database i have some data that i want to extract and put into a text file wich is on that server.
anybody got any ideea how do i write into a text file data from a database using PHP or whateva? jscript does not write text files, but ASP does. any ideea how it's done? PS:the ideea is i have a dynamic dropdown menu which reads from a text file the data to display in itself. and i want that data to be from a datase. i can write smthng to a text file using ASP like this: <% Dim Stuff, myFSO, WriteStuff 'this is what we will write in the file Stuff = "Here is some stuff to write in the file." 'this line creates an instance of the File Scripting Object named myFSO Set myFSO = CreateObject("Scripting.FileSystemObject") 'this line opens the file, notice the 8, it will cause the script to append to the file Set WriteStuff = myFSO.OpenTextFile("myNewText.txt", 8, True) 'this line actually writes STUFF from above to the file WriteStuff.WriteLine(Stuff) ''this line closes the file WriteStuff.Close 'this line destroys the instance of the File Scripting Object named WriteStuff SET WriteStuff = NOTHING 'this line destroys the instance of the File Scripting Object named myFSO SET myFSO = NOTHING %> so...any idea writing an info from a database in that text? |
|
#2
|
||||
|
||||
|
1) Connect to the database (there are examples on how to do this, just do a search)
2) Execute the sql statement to return the data you want. 3) while reading the data from the database, write it to the text file. |
|
#3
|
|||
|
|||
|
can you please be more specific? i dont think i got it wright.
from what you said i understood this is manual... but how do i make writing from the database to the text file in a dynamic way? like generating a text file with the data from a database? i'm a total beginer with asp, or databases so if i stress you...not my intention thx for any help |
|
#4
|
||||
|
||||
|
Example:
Code:
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Your ConnectionString"
Set strSql = "SELECT Username FROM Table1 ORDER BY Username"
Set rs = Conn.Execute(strSql)
if not rs.eof then
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile(Server.MapPath("DataBaseInfo.txt"),2,true)
do until rs.eof
f.WriteLine(rs("Username"))
rs.movenext
loop
f.Close
end if
Conn.Close
Set fs = Nothing
Set Conn = Nothing
|
|
#5
|
|||
|
|||
|
thx for the code. the fact is i cant relly write to a text file .
i'm using domainDLX and this is the link for my test page http://i.domaindlx.com/xilviu/test.asp which suposed to write a testat.txt file using this code i found: Const fsoForAppend = 8 Dim objFSO Set objFSO = Server.CreateObject("Scripting.FileSystemObject") 'Open the text file Dim objTextStream Set objTextStream = objFSO.OpenTextFile("menu_data.js", fsoForAppend) 'Display the contents of the text file objTextStream.WriteLine "Hello, World!" objTextStream.WriteLine "This is fun!!" 'Close the file and clean up objTextStream.Close Set objTextStream = Nothing Set objFSO = Nothing what is wrong here? |
|
#6
|
||||
|
||||
|
Make sure the IUSR_Machinename account has permissions to create/write the file.
|
|
#7
|
|||
|
|||
|
the problem is ... this host give me online control panel and i cannot conect trough ftp. this means i dont have control.
got any tip about a free webhost that works with asp? pls |
|
#8
|
|||
|
|||
|
thank you so much for help. i'm sorry i'd disturbed you.
|
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > very complicated ASP+PHP+SQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|