PHP HELP PLZZZZ

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

Post Reply
yonibensimon
Forum Newbie
Posts: 15
Joined: Thu Aug 07, 2003 10:24 am

PHP HELP PLZZZZ

Post 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 ?
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post 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
yonibensimon
Forum Newbie
Posts: 15
Joined: Thu Aug 07, 2003 10:24 am

Post by yonibensimon »

I haven't read books, but I've read some tutorials.

Here's how i print variables : echo $variable
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post 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?
Last edited by McGruff on Wed Aug 10, 2005 11:12 pm, edited 1 time in total.
yonibensimon
Forum Newbie
Posts: 15
Joined: Thu Aug 07, 2003 10:24 am

Post 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 !
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post 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.
Post Reply