Problem with fopen() function in php

Status
Not open for further replies.

levi2252

New Member
Messages
14
Reaction score
0
Points
0
When I tried to make a php program to allow me to edit a page without going through the cpanel I kept getting this error:

Warning: fopen(style.css) [function.fopen]: failed to open stream: Inappropriate ioctl for device in (will not give page address) on line 6

Anyone have an idea why this happens?
 

levi2252

New Member
Messages
14
Reaction score
0
Points
0
what is this? a help forum or not? I have seen and answered to quite a few other "need help" posts and not a single person can help me?
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Code:
In computing, ioctl (pronounced /aɪˈɒktəl/ or "i-o-control") 
is a system call for device-specific operations and other operations 
which cannot be expressed by regular system calls. It takes a 
parameter specifying a request code; the effect of a call depends 
completely on the request code. Request codes are often 
device-specific. For instance, a CD-ROM driver which can 
get a physical device to eject a disc would provide an ioctl 
request code to do that. Device-independent request codes 
are sometimes used to give userland access to kernel functions 
which are only used by core system software or still under 
development.

Please include the line of code in question next time, it helps.

Check the second argument to fopen, which is the mode. It might not be a valid mode string.
 
Last edited:

levi2252

New Member
Messages
14
Reaction score
0
Points
0
What you mean when using php fopen() it is supposed to be fopen([filename], "W");
If it is I have it right. Otherwise I do not understand.
Here is the code:
<?php
fopen($file, "W");
?>
thats the fopen line.
 
Last edited:

levi2252

New Member
Messages
14
Reaction score
0
Points
0
I got that on a tutorial. but I may have put it in the wrong place. I thought it stood for writeable.
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
The official documentation is a great place to look at, if you get errors.
 

levi2252

New Member
Messages
14
Reaction score
0
Points
0
Ok. now I have it opening but it will not write to the file. here is the full code:
<?php
$file = $_POST['file'];
$content = $_POST['content'];
if(isset($_POST['switch']))
{
fopen($file, "w+");
}
if(isset($_POST['submit']))
{
fwrite($content);
fclose();
}
?>
<form action="<?php $_SERVER['SELF'] ?>" method="POST">
File name:<br />
<input type="text" name="file" /> <input type="submit" name="switch" value="Switch" />
</form>
<form action="<?php $_SERVER['SELF'] ?>" method="POST">
<b>News:</b><br />
<textarea width="150" height="75" name="content" ></textarea><br />
<input type="submit" value="submit"/>
</form>
Anyone know the reason?
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
<input type="submit" value="submit" name="submit"/>
 

levi2252

New Member
Messages
14
Reaction score
0
Points
0
umm. Is this a problem?
Warning: fwrite(): supplied argument is not a valid stream resource in /home/levi2252/public_html/levi224-portfolio.co.cc/---- on line 10
using the same php code except I added the name to the submit button.
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
Why do you have two submit buttons? What is the purpose of "switch" ? You have two forms on the page.
 

levi2252

New Member
Messages
14
Reaction score
0
Points
0
you can close this topic now. The reason for switch was that fopen wasn't working before so I tried a different way.
 
Status
Not open for further replies.
Top