-1

I am working on a school project and seem to be running into a piece that is causing testing to just stop dead. I am getting a

T_CONSTANT_ENCAPSED_STRING

message when trying to log into my program. Here is what I have so far for my code:

$sql = "select * from users where userid='".$userid' and password='".$password'";

login script

ΦXocę 웃 Пepeúpa ツ
  • 47,427
  • 17
  • 69
  • 97

1 Answers1

1

Your query needs to be:

$sql = "select * from users where userid='$userid' and password='$password'";

You can either concatenate the string or you can have the variable directly inside the string but this will only work when there are double quotes.

This will work also and is identical to the query above:

$sql = "select * from users where userid='".$userid."' and password='".$password."'";
Clay
  • 4,700
  • 3
  • 33
  • 49