$query = 'UPDATE inventory SET quantity = quantity+1 WHERE uid=".$uid." && itemid ="1" '
String starts at: 'U in UPDATE.
String ends at: "'
i.e. the whole line is one string. This string is encased in single quotes, so there are no variables in it, only text. Neither is there any string concatenation.
This sequence of characters
=".$uid."
is just that, some characters. equal sign, double quote, full stop etc.
However these lines all end up being the same:
1. $query = 'UPDATE inventory SET quantity = quantity+1 WHERE uid='.$uid.' && itemid =1'
2. $query = "UPDATE inventory SET quantity = quantity+1 WHERE uid=".$uid." && itemid =1"
3. $query = "UPDATE inventory SET quantity = quantity+1 WHERE uid=$uid && itemid =1"
- and 2. work the exact same way (since there are no variables in the singlequote encased strings). They use string concatenation to put the values stored in the variables together with the rest.
- Gives you the same result, but there is no string concat. The double quotes simply leaves variable substitution to the parser.
And if you do need quotes inside your query (which you don't for numbers)
1. $query = "UPDATE inventory SET quantity = quantity+1 WHERE name='$name'"
2. $query = 'UPDATE inventory SET quantity = quantity+1 WHERE name=\''.$name.'\''
Do note that there are no double quotes in the second line, they're just pairs of single quotes, one esacped and one not.
Which, when sent to your database looks like
UPDATE inventory SET quantity = quantity+1 WHERE name='$name'