0

hi guys,

i ran into this error
"Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\web\imagedb\pixel.php on line 19"

while running the code:

<?php
// database connection
$host = "localhost";
$user = "user";
$pass = "password";
$db = "imagedb";
$table= "image";

$conn = mysql_connect($host, $user, $pass)
OR DIE (mysql_error());
@mysql_select_db ($db, $conn) OR DIE (mysql_error());

$image=imageCreateFromJPEG('tulips.jpg');
$x = 10;
$y = 15;
$colorindex = imagecolorat($image,$x,$y);
$colorrgb = imagecolorsforindex($image,$colorindex);

echo "RGB values of the pixel at position $x - $y are: $colorrgb $colorrgb $colorrgb

\n Apha value is: $colorrgb" ;

?>

anybody can explain to me wats wrong?

thanks in advance!

tristan

2
Contributors
1
Reply
2
Views
11 Years
Discussion Span
Last Post by sarahk
0

you have array variables in the string, but the coding is incomplete. it should be

echo "RGB values of the pixel at position {$x} - {$y} are: {$colorrgb['red']} {$colorrgb['green']} {$colorrgb['blue']} \n Apha value is: {$colorrgb['alpha']}" ;

The {} make the world of difference!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.