Jump to content

Writing to .txt file using php


kirstyburgoine

Recommended Posts

Please somebody help me, I am trying to do something that I thought would be very simple!

 

I have a navigation bar that has been created in Flash, I need the URL to change depending on how somebody enters the site. What I thought would be the easiest would be to write my PHP so that I print the correct URL to a text file that flash then links to so the button works correctly.

 

This is my php:

<?

//Pull username from URL

$username = $_GET['member_username'];

 

$artquery="SELECT * FROM `members` WHERE member_username='".$username."' AND okay=1";

$artresult=mysql_query($artquery);

$artdata=mysql_fetch_assoc($artresult);

 

// write url to text file

 

$myFile = "navigation.txt";

$fh = fopen($myFile, 'w+') or die("can't open file");

 

if ($username) {

$stringData = "/".$artdata['member_username']."";

 

} else {

$stringData = "/index.php";

}

 

fwrite($fh, $stringData);

 

fclose($fh);

?>

 

My problem is that I cannot get a variable to print to the text file. I've tried replacing $artdata['member_username'] $member and adding this $member = $artdata['member_username'], I've also tried pulling the username directly from the url using $_GET['member_username'] but still no joy!

 

Does anyone know why this would be?

 

Thanks

 

Kirsty

Link to comment
https://forums.phpfreaks.com/topic/144066-writing-to-txt-file-using-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.