Ashley Posted October 7, 2013 Share Posted October 7, 2013 This statement works fine as it is echo '<p>'.$query_row['name'].'</p>'; But how would it be possible to turn '<p>'.$query_row['name'].'</p>' into a variable that could be called back by a print or echo statement ? A not working example $myvar = '<p>'.$query_row['name'].'</p>'; echo $myvar; Does anyone know how this is possible? Link to comment Share on other sites More sharing options...
HartleySan Posted October 7, 2013 Share Posted October 7, 2013 Your provided "not-working" example should work. What kind of error do you get when you attempt to do it? 1 Link to comment Share on other sites More sharing options...
Ashley Posted October 7, 2013 Author Share Posted October 7, 2013 I don't get any errors, nothing prints out, I assume " " needs to be added somewhere Link to comment Share on other sites More sharing options...
StephenM Posted October 7, 2013 Share Posted October 7, 2013 perhaps the value of $query_row['name'] is empty? Link to comment Share on other sites More sharing options...
HartleySan Posted October 8, 2013 Share Posted October 8, 2013 Ashley, after the page loads, go to the view source option in your browser. As Stephen suggested, likely, the value of $query_row['name'] is an empty string, but the p tags should still be in the markup (even though you don't see anything on the screen). Link to comment Share on other sites More sharing options...
Ashley Posted October 8, 2013 Author Share Posted October 8, 2013 I think I am getting a little further, the p tags do display in the mark up. If i type $myvar = '<p>\'.$query_row[\'name\'].\'</p>'; echo($myvar) prints the code out as '.$query_row['name'].' (I was getting nothing before) and the markup displays as <p>'.$query_row['name'].'</p> when echo '<p>'.$query_row['name'].'</p>' is used the mark up correctly displays <p>Ashley</p> any further ideas ? Link to comment Share on other sites More sharing options...
HartleySan Posted October 8, 2013 Share Posted October 8, 2013 '<p>\'.$query_row[\'name\'].\'</p>' outputs the markup <p>'.$query_row['name'].'</p> and you see '.$query_row['name'].' on the screen because you are escaping some of the single quotes with backslashes, thus making them be interpreted as literals quotes. If you're echoing '<p>'.$query_row['name'].'</p>' and seeing <p>Ashley</p> in your markup, then you should definitely see Ashley on the screen. Are you not seeing that? If so, then you are likely hiding the displaying of that element using CSS or something because by default, <p>Ashley</p> will always output Ashley to the screen. Please let us know. Thanks. Link to comment Share on other sites More sharing options...
Ashley Posted October 8, 2013 Author Share Posted October 8, 2013 Later this week I am seeing some friends who have more coding experience than myself who might be able to solve it, I will keep you updated what happens either way, thank you for your help so far Link to comment Share on other sites More sharing options...
HartleySan Posted October 8, 2013 Share Posted October 8, 2013 You didn't really answer my question, but all the same, I hope you can solve the problem. Please give us the solution once you get it. Thanks. Link to comment Share on other sites More sharing options...
Ashley Posted October 9, 2013 Author Share Posted October 9, 2013 Sorry I did not answer your question HartleySan, I have checked and the CSS is not hiding anything. After checking with a friend I was told I had totally misused single (') and double (") quotation marks in the script which was creating further errors that the text editor did not pick up and I had set the variable outside of the function where it should have been inside of the function therefore the function was unable to access the variable Thank you helping me HartleySan and StephenM Link to comment Share on other sites More sharing options...
Recommended Posts