PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
HuggyBear
Forum Newbie
Posts: 8 Joined: Tue Sep 09, 2003 11:06 am
Location: Atlanta
Post
by HuggyBear » Tue Sep 09, 2003 11:06 am
I've been making this bit of .php to write variables passed from a form to a file on our web hosting server. For some reason, I can't ever seem to find the file even though I think everything is in line.
Feel free to make some suggestions...
Code: Select all
<?
// VARIABLES from FORM //
$first=$_POSTї'firstname'];
$last=$_POSTї'lastname'];
$sitename=$_POSTї'client'];
$email=$_POSTї'adress'];
$sitetype=$_POSTї'group'];
$sitenum=$_POSTї'sites'];
$doctors=$_POSTї'doctors'];
$ris1=$_POSTї'RIS1'];
$ris2=$_POSTї'RIS2'];
$ris3=$_POSTї'RIS3'];
$location=$_POSTї'location'];
// MAKE FILE //
$dataї"1"]=$name;
$dataї"2"]=$email;
$dataї"3"]=$sitename;
$dataї"4"]=$sitetype;
$dataї"5"]=$sitenum;
$dataї"6"]=$doctors;
$dataї"7"]=$location;
$dataї"8"]=$ris1;
$dataї"9"]=$ris2;
$dataї"10"]=$ris3;
$data1=serialize($data);
$path="/tmp/client.txt";
if(is_writable ("$path"))
{
$file=fopen($path, "w") or die("The File $path could not be opened");
fwrite($file, $data1);
fclose($file);
}
if(is_readable ($path))
{
chmod ($path, 0660);
$file=fopen($path, "w") or die("You frigg'n idiot. Quit now!");
fwrite($file, $data1);
echo "true";
fclose($file);
}
?>
Every time I run the script I get the "true" echo for readable...
So that's about all I know. Please help.
Thanks
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Tue Sep 09, 2003 11:19 am
is this line
the
full server path to the file you are wanting to write to/create?
Mark
HuggyBear
Forum Newbie
Posts: 8 Joined: Tue Sep 09, 2003 11:06 am
Location: Atlanta
Post
by HuggyBear » Tue Sep 09, 2003 11:22 am
Well since it's a web hosting server, I don't know if that is the full path...
I had open_basedir problems and :tmp/ was one of the accept paths....
so I have in my main directory a /tmp (standard set-up for the hosting service) and I also have a /tmp in the directory where the .php resides...
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Tue Sep 09, 2003 11:25 am
run this script on your server to get the full server path
Code: Select all
<?
echo $_SERVER["DOCUMENT_ROOT"];
?>
Mark
HuggyBear
Forum Newbie
Posts: 8 Joined: Tue Sep 09, 2003 11:06 am
Location: Atlanta
Post
by HuggyBear » Tue Sep 09, 2003 11:28 am
I get /home/phyque2/public_html...but I have a /tmp in /public_html is the thing... it think that would be right..
Like your sig btw...
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Tue Sep 09, 2003 11:31 am
change
to
Code: Select all
$path="/home/phyque2/public_html/tmp/client.txt";
That should do it
Mark
HuggyBear
Forum Newbie
Posts: 8 Joined: Tue Sep 09, 2003 11:06 am
Location: Atlanta
Post
by HuggyBear » Tue Sep 09, 2003 11:39 am
Bah...this crap is going to drive me crazy.....
No file showed up there dangit....
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Tue Sep 09, 2003 12:02 pm
does client.txt already exist?
if not if(is_writable ("$path")) will not evaluate to true!
try creating a blank txt file in the tmp directory.
Mark
Bizwala
Forum Newbie
Posts: 12 Joined: Tue Sep 09, 2003 12:10 pm
Location: Las Vegas, Nevada
Post
by Bizwala » Tue Sep 09, 2003 12:10 pm
As Mark says above,
You need to have the file clients.txt on the directory. If you have ssh access simply type touch clients.txt in the /tmp directory and make sure it's permissions are writable. Then run the script, that should work. Also make sure that /tmp is a writable directory as well.
This looks like a permission error.
Lani
HuggyBear
Forum Newbie
Posts: 8 Joined: Tue Sep 09, 2003 11:06 am
Location: Atlanta
Post
by HuggyBear » Tue Sep 09, 2003 12:42 pm
Check and Check... I made sure it was a writable .txt and I made sure the dir was writable... to no avail.
Ryan
Bizwala
Forum Newbie
Posts: 12 Joined: Tue Sep 09, 2003 12:10 pm
Location: Las Vegas, Nevada
Post
by Bizwala » Tue Sep 09, 2003 12:58 pm
I just ran the code on my server and it works.
In order to make it work I had to comment out line 42 chmod() line then change permissions on client.txt.
What I am suspecting is apache cannot write to /tmp why not try changing $path to "client.txt" or making a new directory under public_html and placing it there?
Lani
HuggyBear
Forum Newbie
Posts: 8 Joined: Tue Sep 09, 2003 11:06 am
Location: Atlanta
Post
by HuggyBear » Tue Sep 09, 2003 2:03 pm
Well, it must be some settings on the server. I'm going to try to talk to those guys to see what they recommend.
Thanks for the help!