So, I'm learning PHP and I have a question about the part underlined in my screenshot:
http://s18.postimg.org/8el9lkpuh/image.png
I read these related questions and they were generally helpful (and I realize there are security concerns not handled here) but didn't help my understand my specific question:
concatenate mysql select query with php variable?
MySQL query with PHP variables Issues
My question is, why do we need these dots around the variable? Are these concatenation dots? I don't think we are concatenating anything, we're just evaluating a variable, no? And why does it need quotation marks around it? Why can't it simply be "UPDATE table WHERE name=$name" and let $name evaluate to whatever it is..?
In fact, when I try to do that it just doesn't evaluate, but why?
A few lines below, echo "<p>Name: $row[1]</p>";, $row for example evaluates just fine...
EDIT:
$q='UPDATE towels SET name="$name" WHERE id=1';
output: $name
my variable is inside doublequotes, so it should get evaluated, but doesn't?
$q='UPDATE towels SET name="$name" WHERE id=1';
output: $name
variable inside doublequotes, should get evaluated, but doesn't?
$q='UPDATE towels SET name="'.$name.'" WHERE id=1';
output: CORRECT!
variable inside singlequotes, shouldn't get evaluated, but does?
$q="UPDATE towels SET name='$name' WHERE id=1";
output: CORRECT!
variable inside singlequotes, shouldn't get evaluated, but does?
So clearly I'm missing something because it all seems opposite than it should be to me.
.and you can do"UPDATE table WHERE name='$name'"