954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

need help in error

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['red'] $colorrgb['green'] $colorrgb

['blue'] \n Apha value is: $colorrgb['alpha']" ;

?>

anybody can explain to me wats wrong?

thanks in advance!

tristan

tristan17
Junior Poster in Training
51 posts since Sep 2005
Reputation Points: 10
Solved Threads: 1
 

you have array variables in the string, but the coding is incomplete. it should be
[php] echo "RGB values of the pixel at position {$x} - {$y} are: {$colorrgb['red']} {$colorrgb['green']} {$colorrgb['blue']} \n Apha value is: {$colorrgb['alpha']}" ;[/php]The {} make the world of difference!

sarahk
Junior Poster
144 posts since Apr 2005
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You