View Full Version : Simple PHP Problemo
MrPinkPanther
26-03-2009, 03:04 PM
Can anyone see anything wrong with this? A number is sent to the file from an application but the PHP isnt saving it to the text file like it should >.<
<?php
$num = $_POST [‘MyNumber’];
$myFile = “lol.txt”;
$fh = fopen($myFile, ‘w’) or die(“can’t open file”);
fwrite($fh, "My Number is: ");
fwrite($fh, $num);
fclose($fh);
?>
Edit by Robbie! (Forum Super Moderator): Moved to Coding Help, please post in the correct section next time. Thanks!
Protege
26-03-2009, 03:58 PM
Permissions maybe?
Iszak
26-03-2009, 03:58 PM
Besides the fact it looks like it's formated with a word processor and not a text editor - no. If that's your actual code, you should be using double quotes and single quotes " and ' and not the other variations such as “” and ‘’. Otherwise the only other thing I can suggest is ensure that the name of the input being submited is exactly "MyNumber" as it's case sensitive.
Joshh
26-03-2009, 05:16 PM
Hmm it could be a permission error like Protege said, is the file's permissions 0777? If not try changing it to that, and like Iszak said instead of using “” and ‘’ try using "" and '' like so:
<?php
$num = $_POST ['MyNumber'];
$myFile = "lol.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, "My Number is: ");
fwrite($fh, $num);
fclose($fh);
?> If that doesn't work then I cannot suggest anything else eithier, is that the full code? If so then I'm not sure sorry.
Protege
26-03-2009, 06:07 PM
u *REMOVED* repeating lyk
wat me and blutak said!?
Edit by Robbie! (Forum Super Moderator) - Please do not avoid the filter/use inappropriate language.
Joshh
27-03-2009, 09:33 AM
u *REMOVED* repeating lyk
wat me and blutak said!?
Edit by Robbie! (Forum Super Moderator) - Please do not avoid the filter/use inappropriate language.
I was explaining it in abit more detail for him, and it's pretty obvious that to make a file readable, it needs to have the permissions of 0777, anyone with half a brain knows that, that was my first thoughts wether you had posted it or not.
Protege
27-03-2009, 10:01 AM
Yeah, and you're suppose to read everyone elses replies. It might help you and Habboxs poor database of semi-duplicate results.
Joshh
27-03-2009, 05:00 PM
Yeah, and you're suppose to read everyone elses replies. It might help you and Habboxs poor database of semi-duplicate results.
I'll bare that in mind.. :8
Joshh
27-03-2009, 08:35 PM
It was extremely mature to whoever -REPPED me btw.
Edit by Robbie! (Forum Super Moderator): Please do not double post without adding extra information.
Sameer!
27-03-2009, 08:54 PM
I think it's permissions......
Joshh
27-03-2009, 09:00 PM
I think it's permissions......
Eeks, you're not allowed to say that as somebody else has allready thought of it.
Protege
27-03-2009, 09:56 PM
Yet another example of a user who didnt read the ******* thread.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.