Parse error: syntax error, unexpected '=' in path/to/filename.php on line xxx
It is usual to get cryptic error messages when executing php code. It is not intentional but essentially it tells us that the code is not right in just about the indicated area.Take a look at the sentence given below.
variable ="select item from my_images where id =$key";
We will have to look a little ahead and a little behind the "=" symbol, in this case.
But, if you analyse the php program statement carefully, you will notice that you have forgotten to place the mandatory $ sign, which indicates that the word is a php variable.
This is a common error in php.
Place the $ sign before the variable name and all things seem okay.
As to the question of why you need the $ in the first place, it is to declare that this specific word will store some information within.
It provides more clarity to the code and the habit is continued from other programs such as Perl, where a $ is prefixed to define a variable as well.
No comments:
Post a Comment