Narrow screen resolution Wide screen resolution Auto adjust screen size Increase font size Decrease font size Default font size default color grey color red color blue color

Linux Indore - Linux Users Group

Welcome, Guest
Please Login or Register.    Lost Password?

Do you need help with PHP or AJAX, ask here !!!
(1 viewing) (1) Guest
Go to bottomPage: 12
TOPIC: Do you need help with PHP or AJAX, ask here !!!
#32
Do you need help with PHP or AJAX, ask here !!! 2 Years, 8 Months ago Karma: 0
Hi Folks,
If you need any help with PHP and AJAX, ask them here.
I would love to help you in my free time.

Gunjan
smartcoder (User)
null
Fresh Boarder
Posts: 1
graphgraph
User Offline Click here to see the profile of this user
null null null null null null Location: null
The administrator has disabled public write access.
null
 
#39
Re:Do you need help with PHP or AJAX, ask here !!! 2 Years, 6 Months ago Karma: 0

yes sure certainly
basically I am just a click mouse programmer and I always need help every now and then this is delightful for me.

Regards,
Yogesh
swamiyogesh (User)
null
Fresh Boarder
Posts: 1
graphgraph
User Offline Click here to see the profile of this user
null null null null null null Location: null
The administrator has disabled public write access.
null
 
#556
Re:Do you need help with PHP or AJAX, ask here !!! 5 Months, 2 Weeks ago Karma: 0
hi
I have begun learning PHP. I am using Fedora 10. I want to write a script for writing to a text file. For that I used the following code. However, it was not able to create a file.

<html>
<head></head>
<form method="POST">
<pre>
</br> First Name <input type="text" name="first"/>
</br> Last Name <input type="text" name="last"/>
</br> <input type="submit" value="Save the data"/>
</pre>
</form>
<?php
$fp = fopen("names.txt",'a');
if($_POST['first'] and $_POST['last']){
$name= $_POST['first']." ".$_POST['last']."n";
print($name);
fputs($fp,$name);
}
?>
</html>

Also, I checked and found that I had no problem in reading a file. The problem is only with writing a file. Can you please help me in this regard.
ankit.gupta (User)
null
Fresh Boarder
Posts: 16
graphgraph
User Offline Click here to see the profile of this user
null null null null null null Location: null
The administrator has disabled public write access.
null
 
#560
Re:Do you need help with PHP or AJAX, ask here !!! 5 Months, 2 Weeks ago Karma: 3
Two things :

1. Always fclose() the file.

Sample code -

$ourFileName = "testFile.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);


2. If you are trying to get this program to run and you are having errors, you might want to check that you have granted your PHP file access to write information to the directory, where you are trying to create the file. Setting permissions is most often done with command called CHMOD. Use CHMOD to allow the PHP file to write to disk, thus allowing it to create a file.

Let us know, if you get file created.

Happy hacking.
prabhat (Moderator)
Linux Bigot
Moderator
Posts: 87
graphgraph
User Offline Click here to see the profile of this user
Gender: Male CodeRevolts Location: Indore, MP, India Birthday: 10/17
The administrator has disabled public write access.
Prabhat Sandheliya
LinuxIndore.com
 
#565
Re:Do you need help with PHP or AJAX, ask here !!! 5 Months, 1 Week ago Karma: 0
I changed all the permissions. Here is a summary of what I did

Linux Distribution : Fedora 10

Path of the php pages

/var/www/html

I changed the access to the directory html and all the files within it.

Then when I tried to execute the script, it raised a SELinux error "SELinux prevented httpd reading and writing access to http files."It also proposed the solution of executing the command

setsebool -P httpd_unified=1

I executed it both as the user as well as root. However, when I tried to create the file again, I again raised the same SELinux error.

I guess it is the SELinux that is preventing the creation of files.

Please help...

Suggest me what to do now?
ankit.gupta (User)
null
Fresh Boarder
Posts: 16
graphgraph
User Offline Click here to see the profile of this user
null null null null null null Location: null
The administrator has disabled public write access.
null
 
#566
Re:Do you need help with PHP or AJAX, ask here !!! 5 Months, 1 Week ago Karma: 3
Please stop SELinux, its of virtually useless on localhost setup, by issuing the commend (as a root user) :

set enforce = 0

More information click here .

Cheers !
prabhat (Moderator)
Linux Bigot
Moderator
Posts: 87
graphgraph
User Offline Click here to see the profile of this user
Gender: Male CodeRevolts Location: Indore, MP, India Birthday: 10/17
The administrator has disabled public write access.
Prabhat Sandheliya
LinuxIndore.com
 
Go to topPage: 12