sebastiaandraaisma Posted December 23, 2006 Share Posted December 23, 2006 HI I could use some advise for my variable :)I'm using:$title = echo "<strong>".($row["sellrenttext"]).echo ", ".($row["typeofobjecttext"]).echo ", ".($row["city"]).echo ", ".($row["countrytext"]).echo ", ".($row["price"], 0, ',', ' ').echo " ".($row["currencycode"]).echo "</strong>".echo "<BR><BR>".($row["objectdes"]);But I get a Parse error on this line telling meParse error: syntax error, unexpected T_ECHOI was wondering if I could place an echo in a variable or if I maybe forgot something here?(I'm a newbee) ;)Any advise is welcome!Sebas. Quote Link to comment https://forums.phpfreaks.com/topic/31646-variable-advise/ Share on other sites More sharing options...
trq Posted December 23, 2006 Share Posted December 23, 2006 [quote]I was wondering if I could place an echo in a variable[/quote]No. Quote Link to comment https://forums.phpfreaks.com/topic/31646-variable-advise/#findComment-146673 Share on other sites More sharing options...
emehrkay Posted December 23, 2006 Share Posted December 23, 2006 you have the right idea just the wrong execution.do this echo $var = "string".$var2."string2"; Quote Link to comment https://forums.phpfreaks.com/topic/31646-variable-advise/#findComment-146729 Share on other sites More sharing options...
sebastiaandraaisma Posted December 23, 2006 Author Share Posted December 23, 2006 Thank you for your help, I will experiment a little with your sugestion :) Quote Link to comment https://forums.phpfreaks.com/topic/31646-variable-advise/#findComment-146749 Share on other sites More sharing options...
sebastiaandraaisma Posted December 23, 2006 Author Share Posted December 23, 2006 I now tried:$title = $var = echo "<strong>".($row1["sellrenttext"]).", ".($row2["typeofobjecttext"]).", ".($row3["city"]).", ".($row4["countrytext"]).", ".($row5["price"], 0, ',', ' ')." ".($row6["currencycode"])."</strong><BR><BR>".($row7["objectdes"]);and also:$title = echoinstead of $title = $var = echoBut I get the same "Parse error: syntax error, unexpected T_ECHO" error on this line.I must be doing somrthing wrong, its just that I can't see what :)Any help is welcome!Kind regards,Sebastiaan Quote Link to comment https://forums.phpfreaks.com/topic/31646-variable-advise/#findComment-146774 Share on other sites More sharing options...
genericnumber1 Posted December 23, 2006 Share Posted December 23, 2006 you.. cant put an echo like that into a variable? :-\ I cant see any practical use in that or how you would even use it... you could do like$title = 'stuff' . $aVariable . 'morestuff' . $maybeAnotherVariable;echo $title; Quote Link to comment https://forums.phpfreaks.com/topic/31646-variable-advise/#findComment-146776 Share on other sites More sharing options...
Jessica Posted December 23, 2006 Share Posted December 23, 2006 Why do you want to put echo in a variable? I think you mean you want to echo the variable. [code]$var = "<strong>".($row1["sellrenttext"]).", ".($row2["typeofobjecttext"]).", ".($row3["city"]).", ".($row4["countrytext"]).", ".($row5["price"], 0, ',', ' ')." ".($row6["currencycode"])."</strong><BR><BR>".($row7["objectdes"]);echo $var;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/31646-variable-advise/#findComment-146778 Share on other sites More sharing options...
sebastiaandraaisma Posted December 23, 2006 Author Share Posted December 23, 2006 Yes, you are both right. It was not my intention to echo something inside a variable but echo the variable :)I'm just verry new and though that this was the proper way to insert strings and variables inside a new one.I have tried both your solutions (single quotes and double quotes) I no longer get the echo error but now I see this one:Parse error: syntax error, unexpected ','The code looks now like this:$title = "<strong>".($row1["sellrenttext"]).", ".($row2["typeofobjecttext"]).", ".($row3["city"]).", ".($row4["countrytext"]).", ".($row5["price"], 0, ',', ' ')." ".($row6["currencycode"])."</strong><BR><BR>".($row7["objectdes"]);I also tried:$title = '<strong>'.$sellrent.', '.$typeobject.', '.$city.', '.$country_1.', '.$currency.'</strong><BR><BR>'.$short_des;Hereby I had extracted the variables and created new ones, sounds complicated I know ;)What I try to accomplish is that it generates some text inside a variable that I will use for a google map on my website :)I just need to get this variable to work before I can experiment any further :)All advise is apriciated and welcome.Kind regards,Sebas Quote Link to comment https://forums.phpfreaks.com/topic/31646-variable-advise/#findComment-146789 Share on other sites More sharing options...
trq Posted December 23, 2006 Share Posted December 23, 2006 That variable will work fine.[code=php:0]$title = '<strong>'.$sellrent.', '.$typeobject.', '.$city.', '.$country_1.', '.$currency.'</strong><BR><BR>'.$short_des;echo $title;[/code] Quote Link to comment https://forums.phpfreaks.com/topic/31646-variable-advise/#findComment-146792 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.