This one line of CODE won't work

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
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

This one line of CODE won't work

Post by Benjamin »

Ok after 2 hours of being totally confused about why some code which I copied straight out of a book doesn't work, I decided maybe some of you could help me.

What I did is took this one line of code and threw it into a a file called text.php

<?php echo $author; ?>

Then I pulled up http://localhost/text.php?author=test

And walla.... A blank page EVERYTIME.

Yes I have IIS and PHP installed. Please Help this is driving me crazy. :cry:
lc
Forum Contributor
Posts: 188
Joined: Tue Apr 23, 2002 6:45 pm
Location: Netherlands

Post by lc »

how about

Code: Select all

<?php echo "$author"; ?>
try that. but it should have worked
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Nope

Post by Benjamin »

I tried your code above, that doesn't work either.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<?php echo $author; ?>
</body>
</html>

That code works on my remote server, but not on my local machine.
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

are you running PHP 4.2.0? 'cause if so then globals are not auto registered. you can either change the php.ini to reflect this or access the variable through $_GET['author']
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Got it

Post by Benjamin »

Ok I got it to work, apparently I didn't copy the php.ini file into the system directory.
Post Reply