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
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Sat Feb 21, 2004 12:42 pm
Here's the full test i did anyway
Code: Select all
<?php
$n = 'one';
$a = 'two';
$l = 'three';
$fm= 'four';
$ach = 'five';
$pc = 'six';
$le = 'seven';
$r = 'eight';
$q = 'nine';
$pw = 'ten';
$results = "<?php
\$name = "$n";
\$age = "$a";
\$location = "$l";
\$fmap = "$fm";
\$achievements = "$ach";
\$pastclan = "$pc";
\$lexp = "$le";
\$resolution = "$r";
\$quote = "$q";
\$p = "$pw";
?>";
$fp = fopen('code.php', 'w');
fputs($fp, $results);
fclose($fp);
?>
defx
Forum Commoner
Posts: 36 Joined: Mon Feb 16, 2004 11:50 pm
Location: Florida, USA
Post
by defx » Sat Feb 21, 2004 12:46 pm
what kind of file are you writing it too mark? because im writing it to a php file and it doesnt show up when i open it up in ultraedit :O
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Sat Feb 21, 2004 12:47 pm
Just writing it to a file called code.php
Illusionist
Forum Regular
Posts: 903 Joined: Mon Jan 12, 2004 9:32 pm
Post
by Illusionist » Sat Feb 21, 2004 12:51 pm
Ok mark the first time i tried it without escaping the ; it didn't work... but for some reason it does now.. ig uess soemthing else was wrong with my code! eheh
defx
Forum Commoner
Posts: 36 Joined: Mon Feb 16, 2004 11:50 pm
Location: Florida, USA
Post
by defx » Sat Feb 21, 2004 12:51 pm
this is weird, i open up the page, "write" it, then open the file its supposed to write to, and nothing is there
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Sat Feb 21, 2004 12:54 pm
I notice you are doing
Code: Select all
$fp = fopen("$file", "w");
fwrite($fp, $results);
Try doing this :
Code: Select all
echo "Writing to $file<br />";
$fp = fopen($file, "w");
fwrite($fp, $results);
fclose($fp); See if the echo looks ok.
defx
Forum Commoner
Posts: 36 Joined: Mon Feb 16, 2004 11:50 pm
Location: Florida, USA
Post
by defx » Sat Feb 21, 2004 12:56 pm
nope, still doesnt work ;O -- could i be doing something wrong as far as defining the file goes, since it isnt in the function?
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Sat Feb 21, 2004 12:58 pm
What did the echo output? 'Writing to ...... '?
If you put error_reporting(E_ALL); right after <?php then it will throw up undefined vars like $file
Illusionist
Forum Regular
Posts: 903 Joined: Mon Jan 12, 2004 9:32 pm
Post
by Illusionist » Sat Feb 21, 2004 1:00 pm
i think i found your problem:
Code: Select all
} elseif ($p == "edit" && $user == "defx") {
$file = "defx.php";
} elseif ($p == "submit") {
submit();
}
If your just trying to test the submit, then you'll never define the file...
defx
Forum Commoner
Posts: 36 Joined: Mon Feb 16, 2004 11:50 pm
Location: Florida, USA
Post
by defx » Sat Feb 21, 2004 1:01 pm
no i am full out using the page. i am going to page.php?p=edit&user=defx and it still doesnt work :O
Illusionist
Forum Regular
Posts: 903 Joined: Mon Jan 12, 2004 9:32 pm
Post
by Illusionist » Sat Feb 21, 2004 1:02 pm
thats ebcause your never calling submit() then.... Just going to page.php?p=edit&user=defx will just define $file... it will never run submit()
defx
Forum Commoner
Posts: 36 Joined: Mon Feb 16, 2004 11:50 pm
Location: Florida, USA
Post
by defx » Sat Feb 21, 2004 1:03 pm
see im wondering if its because i only go to ?p=submit when it submits
defx
Forum Commoner
Posts: 36 Joined: Mon Feb 16, 2004 11:50 pm
Location: Florida, USA
Post
by defx » Sat Feb 21, 2004 1:04 pm
well like what im doing is going to page.php?p=edit&user=defx there the form code shows up, im putting in info and hitting submit, which is linked to ?p=submit
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Sat Feb 21, 2004 1:05 pm
Do you have register_globals On? If not it won't work, you'll need to use $_GET['p'] where you have $p, and $_GET['user'] where you have $user etc..
Illusionist
Forum Regular
Posts: 903 Joined: Mon Jan 12, 2004 9:32 pm
Post
by Illusionist » Sat Feb 21, 2004 1:05 pm
i know waht you can do though... add a hidden input field in your big echo that echo's out he HTML, and give it a name of file and assign it's value to $file.
<input type=\"hidden\" name=\"file\" value=\"$file\">