sOnt sOnt - 16 days ago 5
MySQL Question

Syntax error in php code

I'm a bit confused about the syntax of php.

I am trying to do a query without success and I'm stucked here for 2 days.

$query = ('UPDATE cegek SET CegNev='."$cegnev".', Kozpont='."$kozpont".', Bevetel='."$bevetel".', Alkalmazottak='."$alkalmazott".', Iparag='."$iparag".' WHERE id='."$id");


This returns
Parse error: syntax error, unexpected '$cegnev' (T_VARIABLE) in


I tought that "" for variables and '' for string.

Anyone can help?

Answer

Should use concatenation operator ('.') between two strings

Try this

$query = ("UPDATE cegek SET CegNev='".$cegnev."', Kozpont='".$kozpont."', Bevetel='".$bevetel."', Alkalmazottak='".$alkalmazott."', Iparag='".$iparag."' WHERE id=".$id."");