You are here: writing files to a choosen directory « All PHP « IT news, forums, messages
writing files to a choosen directory

Posted by Ian Davies on 11/06/05 17:26

Hello
I have the following code which changes directory, creates a file and then
writes rows to it. It works fine except the file is created in the folder
the php script is in instead of the download directory specified in the
scrip. Can anyone see where I have gone wrong
Also I want to show the question Index and Question on screen as a list.
Ive put

echo $nt['QuestionIndex'], $nt['Question'];

here <<<<<<<<<<<<<<<< in the script
but it doesnt work, any ideas?

Ian

******************************
$query= "SELECT * FROM Questions WHERE NCIndex='".$_SESSION['NCI']."' AND
QuestionIndex IN (".join(",", $_SESSION['questions']).") ORDER BY
QuestionIndex";

$rt=mysql_query($query)
or die(mysql_error());
echo mysql_error();

if (ftp_chdir($conn_id, "../htdocs/Downloads")) {
echo "Current directory is now: " . ftp_pwd($conn_id) . "\n";

}else {
echo "Couldn't change directory\n";
}
$fp = fopen('ptq'.$_SESSION['username'].time().'.txt', 'w')
or die('Could not open the text file for writing');
while ($nt = mysql_fetch_array($rt, MYSQL_NUM)){

$line = "INSERT INTO tQuestions VALUES ('', '" .
implode("', '", $nt) .
"');\r\n";
fwrite($fp, $line);
echo $nt['QuestionIndex'], $nt['Question']; <<<<<<<<<<<<<<<
}
fclose($fp);

***************************

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация