rick_8040 Posted December 5, 2022 Share Posted December 5, 2022 I have a url link that is fetch from a mysql database. $id=5; $link->link_url="details.php?id={$id}"; echo $link->link; output: details.php?id={$id} I need it to output: details.php?id=5 How can I do this? I need the url link so I can use it in different area of the website. Any help will be greatly appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/315614-need-help-coding-php/ Share on other sites More sharing options...
Barand Posted December 5, 2022 Share Posted December 5, 2022 2 hours ago, rick_8040 said: $link->link_url="details.php?id={$id}"; Are you sure that is your actual code? Quote Link to comment https://forums.phpfreaks.com/topic/315614-need-help-coding-php/#findComment-1603267 Share on other sites More sharing options...
ginerjm Posted December 5, 2022 Share Posted December 5, 2022 This code: $link->link_url="details.php?id={$id}"; echo $link->link; Why is it like that? If you don't want to output something with braces in it, why do you assign the braces to it? And if you are making an assignment to a class var named 'link_url' why then do you output a var named 'link'? And if that url value is truly coming from a mysql database, why not update your database entry? Quote Link to comment https://forums.phpfreaks.com/topic/315614-need-help-coding-php/#findComment-1603269 Share on other sites More sharing options...
rick_8040 Posted December 5, 2022 Author Share Posted December 5, 2022 10 hours ago, rick_8040 said: I have a url link that is fetch from a mysql database. Is stored in mysql database as "details.php?id={$id}" $id=5; $link->link_url="details.php?id={$id}"; echo "<li><a href='".$link->link_url."' title="">".$link->)link_name."</a></li>"; output: echo "<li><a href='"details.php?id={id}"' title=''>".$link->)link_name."</a></li>"; I need it to output: echo "<li><a href='"details.php?id=5"' title=''>".$link->)link_name."</a></li>"; details.php?id=5 How can I do this? I need the url link so I can use it in different area of the website. Any help will be greatly appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/315614-need-help-coding-php/#findComment-1603271 Share on other sites More sharing options...
Barand Posted December 5, 2022 Share Posted December 5, 2022 11 hours ago, Barand said: Are you sure that is your actual code? I ask because your output is showing the symptoms of using single quotes around the string instead of double quotes. That is $link->link_url='details.php?id={$id}'; intead of $link->link_url="details.php?id={$id}"; Quote Link to comment https://forums.phpfreaks.com/topic/315614-need-help-coding-php/#findComment-1603272 Share on other sites More sharing options...
rick_8040 Posted December 7, 2022 Author Share Posted December 7, 2022 "details.php?id={$id}" is stored in the mysql database. I assign $id=5; I echo $link->link_url; php echo "details.php?id={id}" I need to echo "details.php?id=5" Quote Link to comment https://forums.phpfreaks.com/topic/315614-need-help-coding-php/#findComment-1603308 Share on other sites More sharing options...
ginerjm Posted December 7, 2022 Share Posted December 7, 2022 Your last post makes no sense at all. You can't write code that looks like that. Why are you storing this supposed code in a database table? Why not just write it? Why include braces in it when they are clearly not needed? As Barand has already said it appears that your supposed php code may be stored or retrieved through single quotes and not double ones, thus it does not get translated the way you want. So - what is our point in storing code in a table since you are clearly a noob at coding? Quote Link to comment https://forums.phpfreaks.com/topic/315614-need-help-coding-php/#findComment-1603310 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.