code not working, why :O

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

User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Here's the full test i did anyway :o

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 »

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
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

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 »

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 »

this is weird, i open up the page, "write" it, then open the file its supposed to write to, and nothing is there
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

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 »

nope, still doesnt work ;O -- could i be doing something wrong as far as defining the file goes, since it isnt in the function?
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

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 »

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 »

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 »

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 »

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 »

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
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

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 »

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\">
Post Reply