concat trouble

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jonah
Forum Commoner
Posts: 31
Joined: Fri Jun 20, 2003 12:23 am

concat trouble

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
jonah
Forum Commoner
Posts: 31
Joined: Fri Jun 20, 2003 12:23 am

Post by jonah »

Thanks, that did work.

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