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,030
  • 21
  • 100
  • 124
Mr. Dynamic
  • 479
  • 3
  • 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'] . "'";
Tim Cooper
  • 151,519
  • 37
  • 317
  • 271
1

You need to concatenate your string:

$qry = "SELECT * FROM members WHERE member_id='" . $_SESSION['SESS_MEMBER_ID'] . "'";
cmbuckley
  • 36,905
  • 8
  • 73
  • 90
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
  • 141,508
  • 20
  • 234
  • 284
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,724
  • 45
  • 120
  • 188
0
$qry="SELECT * FROM members WHERE member_id='" . $_SESSION['SESS_MEMBER_ID'] . "'";

You must concentrate your strings with . operator