-1

I wonder what is wrong with this select statement. this is the error i am getting:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/www/mp28.bit-mp.biz/CardRegistration2.php on line 47

$query = "SELECT PlayerName FROM Players where TeamName = .$row['Team1']";
kamal pal
  • 4,187
  • 5
  • 25
  • 40
MOHW
  • 1
  • 2

3 Answers3

1
$query = "SELECT PlayerName FROM Players where TeamName = .$row['Team1']";

should be

$query = "SELECT PlayerName FROM Players where TeamName = '{$row['Team1']}'";
kamal pal
  • 4,187
  • 5
  • 25
  • 40
  • I want to populate a dropdown list with values from two different columns e.g. Away vs Home xxx vs yyy I want to populate a dropdowlist: --select-- xxx yyy Anyone can help me with this?? – MOHW Jan 28 '16 at 08:26
0

Query correction check two solutions. Both should work:

$query = "SELECT PlayerName FROM Players where TeamName =" .$row['Team1'];

OR

$query = "SELECT PlayerName FROM Players where TeamName ='" .$row['Team1'] . "'";

Concatenation issue at TeamName =

AddWeb Solution Pvt Ltd
  • 21,025
  • 5
  • 26
  • 57
0
$query = "SELECT PlayerName FROM Players where TeamName = '".$row['Team1']."' ";

Try this. TeamName column is varchar so passing string enclosed with quotes.

Shailesh Katarmal
  • 2,757
  • 1
  • 12
  • 15