Sessions Are not Working [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
hi i want to start a session of user but i am unable to do that. i have see examples of it also but my problem is still the same. i am getting this error
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a2277283/public_html/scripts/login.php on line 11
here is my code
<?php
ob_start();
session_start();
include 'db.php';
if (isset($_POST['submit'])) {
echo $email = $_POST['user_email'];
$sql = "select * from user where `user_email` = '$email'";
if (mysql_query($sql)) {
$_SESSION['email'] = $email;
echo "$_SESSION['email']";
}
}
?>

the problem is:
echo "$_SESSION['email']";
Use without quotes like:
echo $_SESSION['email'];
or
echo "$_SESSION[email]";
or
echo "{$_SESSION['email']}";

Echo the session variable like this: echo "{$_SESSION['email']}"; as described at the PHP Docs

Related

PHP echo same function twice [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to echo a paging function twice,
echo blaetterfunktion($seite, $wieviele_seiten);
content
echo blaetterfunktion($seite, $wieviele_seiten);
I guess that would burden the server twice?
What can I do to have the server burdened just once and still echo it twice?
Place the result of the function in a variable:
<?php
$result = blaetterfunktion($seite, $wieviele_seiten);
echo $result;
?>
content
<?php
echo $result;
?>
Save it to a variable:
<?php
$variable = blaetterfunktion($seite, $wieviele_seiten);
echo $variable;
?>
content
<?php
echo $variable;
?>

Parse error: syntax error, unexpected '.' in PHP? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am getting Parse error: syntax error, unexpected '.' in C:\xampp\htdocs\PHPExercise\go4shop\header.php as
php require("bar.php");
echo "<hr />";
if (isset($_SESSION['SESS_LOGGEDIN']) == T RUE) {
echo "Logged in as <strong>".$_SESSION['SESS_USERNAME']."</strong>[<a href=" & quot;.$config_basedir. & quot;
logout.php ">logout</a>]";
} else {
echo "<a href=" & quot;.$config_basedir. & quot;
login.php ">Login</a>";
}
Rewrite your code. Use the below code:
php require("bar.php");
echo "<hr/>";
if (isset($_SESSION['SESS_LOGGEDIN'])) {
echo "Logged in as <strong>".$_SESSION['SESS_USERNAME']."</strong>[<a href='".$config_basedir."logout.php'>logout</a>]";
} else {
echo "<a href='".$config_basedir."login.php'>Login</a>";
}
Remove the " from the code. And make the code workable.

Getting syntax error when using shorthand if/else code [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Can anyone tell me what is wrong with the below shorthand if/else code?
<div class="holder <?php echo (!empty($bid_info['sale_price'] ? 'holder7' : 'holder4'); ?>">
According to this page it seems right!?
Though I am getting the below error:
Parse error: syntax error, unexpected '?', expecting ')' in ...........
Missing ) before the ?
<?php echo (!empty($bid_info['sale_price']) ? 'holder7' : 'holder4'); ?>

Parse error: syntax error, unexpected '{' [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Tried a few things, I am sure this is a minor error but I have been staring at it for ages!
if (isset ($_GET['id']) { $product_id = strip_tags($_GET['id']); }
Can anyone see what is wrong?
You're missing a ):
if (isset ($_GET['id'])) { $product_id = strip_tags($_GET['id']); }
^
you are missing first started small bracket.
(isset ($_GET['id']) -- here ) should be closed like.
if (isset ($_GET['id'])) { $product_id = strip_tags($_GET['id']); }

T_VARIABLE parse error [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I saw here about my problem PHP Script to Edit DNS Records in CPanel but When I try to use the dnsclass.php.
I can create a object like this:
$zones = new zone_records("cpaneluser", "pass", "website_to_login", "domain_of_records")
But I can't use this:
$zones->addrecord($type, $target, $name, $ttl)
I'm having this problem :
Parse error: syntax error, unexpected T_VARIABLE in /home/mcser325/public_html/test.php
My code:
include 'classdns.php';
$zones = new zone_records("**", "**", "**", "**")
$zones->addrecord("**", "**", "**", "**")
There is no semicolon at the end of the statement which is causing the error.

Categories