![]() |
not echoing correctly
The echo is not echoing please help
Code:
<?php session_start(); ?> |
You're not giving us much to start with. Presumably you put something in $_SESSION['username'] somewhere, and now when you print it, it's not showing up?
Dave |
This is the code where I have session variables
Code:
<?php |
Two things... I don't see a call to session_start() in that second routine, and then I see a random statement:
Code:
$_SESSION['username'];Code:
$_SESSION['username'] = $username; |
It looks like you're making a login script, but it's not really doing anything. Inside the count if, you should be assigning variables - not just stating them randomly. It should be $_SESSION['username'] = $variable etc. You really should know how variables work if you're attempting programming.
Also, you don't need encapsulation when echo'ing variables in PHP. echo $name; will work just fine. Using encapsulation ("'s) like you're doing will also work, but takes longer as php takes it as a string, then parses the value for $name inside the string. While you're learning, you should note the difference between ' and ". Encapsulating text in ' will tell php to treat it as plain text, whereas encapsulating a string in " will tell php to parse any variables inside it as their value. An example of that: PHP Code:
|
Quote:
session_start() is required at the top of all pages that are going to use sessions. |
I do have session start at the top
Code:
<?php session_start(); ?> |
Not in the script you pasted in post #3 you don't. The script you're setting (or trying to set in your original case) session variables. And please lads, use php tags instead of code tags.
|
if those scripts are just a small part of yr complete code (that relates to this problem) then the problem may lie somewhere else. otherwise as what other posters have said, you are not passing any value into your Session[username] at all.
|
Quote:
But, it's logical to assume that there could be errors in other files as well - just nothing that will relate to this immediate problem. |
| All times are GMT +1. The time now is 01:41 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.