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

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.