-1

I have got a PHP syntax error called

Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\playit2\rental_list.php on line 189

The line 189 is

$jsql_ae3 = mysql_query("select products.formats from products where products.id='$jrowa2['id']'") or die(mysql_error());
Amare
  • 685
  • 2
  • 8
  • 22
  • Have you tried changing `where products.id='$jrowa2['id']'"` to `where products.id='{$jrowa2['id']}'"` – Justinas Dec 09 '14 at 11:14

8 Answers8

2

Using a PHP IDE with syntax highlighting such as NetBeans or PHPStorm.

In this particular case, you can insert a pair of brackets between the single quotes and the array access to fix this line:

$jsql_ae3 = mysql_query("select products.formats from products where products.id='{$jrowa2['id']}'") or die(mysql_error());
Marcel Hernandez
  • 1,371
  • 13
  • 22
  • It doesn't need to be an IDE. A source code editor with syntax highlighting is enough, like Notepad++. At least for me it's enough. – Charlotte Dunois Dec 09 '14 at 11:18
2

With arrays and functions, you need to put curley braces:

$jsql_ae3 = mysql_query("select products.formats from products where products.id='{$jrowa2['id']}'") or die(mysql_error());
Antony D'Andrea
  • 991
  • 1
  • 16
  • 35
2

When you use an array like this

$jrowa2['id']

inside a string with double quotes, PHP you do interpolation and try to interpret it, but, in this case, you can't use the simple quotes surrounding the key, you just have write the key (because it's already inside a string), then, you just use

$jrowa2[id]
1

It should be -

"select products.formats from products where products.id='$jrowa2[id]'"
Sougata Bose
  • 31,517
  • 8
  • 49
  • 87
1

Change with this

$jsql_ae3 = mysql_query("select products.formats from products where products.id='$jrowa2[id]'") or die(mysql_error());
tzafar
  • 674
  • 3
  • 12
0

php_check_syntax should do the job for you. However this is only if you're running PHP >= 5.05. The first comment in the comments section will show you how to implement.

YaBCK
  • 2,949
  • 4
  • 32
  • 61
0
$jsql_ae3 = mysql_query("select products.formats from products where products.id='".$jrowa2['id']."'") or die(mysql_error());
websky
  • 3,047
  • 1
  • 33
  • 31
0

Try this.

 $jsql_ae3 = mysql_query("select products.formats from products where products.id="$jrowa2['id']"") or die(mysql_error());

Hope this helps.

user247217
  • 394
  • 1
  • 9