Page 1 of 1

concat trouble

Posted: Sat Apr 15, 2006 8:07 am
by jonah
I may be attempting to do something that is impossible.

I am trying to produce an html code string which includes database info,
but am trying to include the evaluation in the string rather than assigning
it to a variable first:

Code: Select all

for ( $n = $numrows; $n > 0; $n-- ) {
echo "<tr><td align='right'>" . mysql_result($r1,$n,"PIN"); . "</td><td bgcolor='yellow'>" . mysql_result($r1,$n,"Name"); . "</td></tr>";}
I get the error message: parse error: unexpected '.'

I realize that I am probably not concatenating a 'string' with the mysql_result. I can
assign the mysql_result to a variable and then use something like:

Code: Select all

for ( $n = $numrows; $n > 0; $n-- ) {
echo "<tr><td align='right'>" , $var , "</td> ...
but I am looking for a way to streamline the code and avoid a large number of variable
assignments.

I have not been able to find a function that will convert the mysql_result output to a
string, although there must be some way to do that.

Any help appreciated.

Posted: Sat Apr 15, 2006 9:18 am
by feyd
a semicolon denotes the last command of a statement. If you remove the semicolons from the line (except for the last one) it should work.

Posted: Sat Apr 15, 2006 10:10 am
by jonah
Thanks, that did work.

I keep getting confused as I continually jump
between Javascript, vbScript and PHP.