0

I have been staring at this for 20 minutes now and I can't figure out what I'm doing wrong.

// Create query
$qry = "SELECT * FROM members WHERE member_id='"$_SESSION['SESS_MEMBER_ID']"'";
$result = mysql_query($qry);

Parse error: syntax error, unexpected T_VARIABLE in /home/dkitterm/public_html/test2/member-profile.php on line 24

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Mr. Dynamic
  • 499
  • 4
  • 6
  • 11

5 Answers5

5

You need to concatenate the string literals with the variable with the . operator:

$qry = "SELECT * FROM members WHERE member_id='" . $_SESSION['SESS_MEMBER_ID'] . "'";
1

You need to concatenate your string:

$qry = "SELECT * FROM members WHERE member_id='" . $_SESSION['SESS_MEMBER_ID'] . "'";
cmbuckley
  • 40,217
  • 9
  • 77
  • 91
1

The less cumbersome approach is using string interpolation. You're already in a double quoted string, so why not utilize its one distinct feature?

$qry="SELECT * FROM members WHERE member_id='{$_SESSION['SESS_MEMBER_ID']}'";

That's terser and less room for syntax errors.
See also http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double (There's a shorter syntax even, if you read on.)

mario
  • 144,265
  • 20
  • 237
  • 291
0

Change it to:

 //Create query
 $qry="SELECT * FROM members WHERE member_id='" . $_SESSION['SESS_MEMBER_ID'] . "'";
 $result=mysql_query($qry);

You forgot the concatenation operator, .

Cyclone
  • 17,939
  • 45
  • 124
  • 193
0
$qry="SELECT * FROM members WHERE member_id='" . $_SESSION['SESS_MEMBER_ID'] . "'";

You must concentrate your strings with . operator