Jump to content

[SOLVED] syntax error


alienmojo

Recommended Posts

ok i need some more help this is why i didnt make is solved


ok this is the code im using
echo "<a href=\"editentries.php?accountnum='.$accountnum.'\">{$row['address']}</a>";

when you click on the link this is th address
http://24.116.162.98:8080/editentries.php?accountnum='.1.'

i need it to look like this
http://24.116.162.98:8080/editentries.php?accountnum=1

Link to comment
https://forums.phpfreaks.com/topic/33282-solved-syntax-error/#findComment-155507
Share on other sites

Let me explain to you how echoing works.

Echo can start with " or ', thought out your whole text if your echo started with this, a second one will close. They are not interchangeable. In this case you started with " so if you wanted to end you had to end with "

With this knowledge the proper way would be:

echo "<a href=\"editentries.php?accountnum=".$accountnum."\">{$row['address']}[/url]";

But you don't even need to end in this case. Alternatively you could use the following with the same results

echo "<a href=\"editentries.php?accountnum={$accountnum}\">{$row['address']}[/url]";

Placing a variable in butterfly brackets is smaller text wise, cleaner and it looks a lot sexier if you ask me.

Now when would you use " . . ", well this is best used when you call a function. Functions cannot be called in the text. They will always just be displayed in text.

I hope this helps. :)
Link to comment
https://forums.phpfreaks.com/topic/33282-solved-syntax-error/#findComment-155512
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.