need help in error

Reply

Join Date: Sep 2005
Posts: 51
Reputation: tristan17 is an unknown quantity at this point 
Solved Threads: 1
tristan17 tristan17 is offline Offline
Junior Poster in Training

need help in error

 
0
  #1
Dec 13th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 138
Reputation: sarahk is an unknown quantity at this point 
Solved Threads: 1
sarahk's Avatar
sarahk sarahk is offline Offline
Junior Poster

Re: need help in error

 
0
  #2
Dec 14th, 2005
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!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC