Page 1 of 1

PHP HELP PLZZZZ

Posted: Fri Aug 08, 2003 10:10 am
by yonibensimon
I'm quite new to PHP. My scripts work very well on a PHP editor. But when i run them from my browser, the content of my variables do not appear when I print them !!!

Can anyone help me ?

Posted: Fri Aug 08, 2003 11:11 am
by m3rajk
how are you trying to print them?

from your posts i get the feeling you've never opened a book. fyi: read twig's posting guidlines, because the fact i get that feeling is a bad sign.. it means people are going to stop answering you soon because they feel you want us to do work you should do before bringing questions here. which means either the construction of your questions are bad, or you need to read a book

Posted: Fri Aug 08, 2003 11:33 am
by yonibensimon
I haven't read books, but I've read some tutorials.

Here's how i print variables : echo $variable

Posted: Fri Aug 08, 2003 7:50 pm
by McGruff
This might not be the problem but are you echoing vars in an included html template?

In an html file, you need to jump into php before you can echo (and then jump out again) ie:

Code: Select all

<?php echo $var; ?>
The parser won't do anything unless it sees the php tags.

If you are echoing direct from php, the code you posted doesn't have a ";" at the end of the line: are you getting error messages for that?

Posted: Mon Aug 11, 2003 10:23 am
by yonibensimon
Yes, i included the ";".

I can't figure out why it doesn't print them. I just noticed in the editor it says (for the variables that do not print), ": Undefined variable: RefName in...". But the variable has been defined in my html form !

Posted: Mon Aug 11, 2003 2:03 pm
by McGruff
Scuse me if I'm telling you something you already know but first some basics about scripts.

When a php script has finished, everything associated with it - vars, fn defs etc - disappears. So, in one script you create a form, the script runs and all the vars in that script are gone. When the form is submitted, a new script starts and you have to declare vars again. These will be in the $_POST array (if POST was your form method). If register globals is off, get them with:

Code: Select all

<?php
$var = $_POST['var']
?>
.. or just use $_POST['var'] wherever you need it.