[SOLVED] Slight Problem Undefined Variable

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
Themodem
Forum Newbie
Posts: 6
Joined: Mon Feb 23, 2004 8:53 am
Location: Keighley, UK

[SOLVED] Slight Problem Undefined Variable

Post by Themodem »

Hi all
im just messing around with php and have hit a problem

ive got some simple code

Code: Select all

<?php echo("$name"); ?>
and i keep getting Notice: Undefined variable: name error.

Can anyone help me?

i am using EasyPHP

Cheers Lee
Last edited by Themodem on Mon Apr 19, 2004 8:53 am, edited 1 time in total.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

you need to do something like this

Code: Select all

$name = "Mark"; // Define the variable

echo $name; // Use the variable
Mark
Themodem
Forum Newbie
Posts: 6
Joined: Mon Feb 23, 2004 8:53 am
Location: Keighley, UK

Post by Themodem »

i should have put the reason for the code

i am using it so i can use a link like

index.php?name=Lee

The error is fixed but the name still doesnt appear

Cheers Lee
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

ah, if you are passing the name through the query string, you will need to do this

Code: Select all

$name = $_GET['name'];// Define the variable 

echo $name; // Use the variable
Themodem
Forum Newbie
Posts: 6
Joined: Mon Feb 23, 2004 8:53 am
Location: Keighley, UK

Post by Themodem »

Works like a charm thanks :D
Post Reply