Jump to content

Variable advise


sebastiaandraaisma

Recommended Posts

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 me
Parse error: syntax error, unexpected T_ECHO

I 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.
Link to comment
https://forums.phpfreaks.com/topic/31646-variable-advise/
Share on other sites

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 = echo
instead of $title = $var = echo

But 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
Link to comment
https://forums.phpfreaks.com/topic/31646-variable-advise/#findComment-146774
Share on other sites

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]
Link to comment
https://forums.phpfreaks.com/topic/31646-variable-advise/#findComment-146778
Share on other sites

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
Link to comment
https://forums.phpfreaks.com/topic/31646-variable-advise/#findComment-146789
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.