Jump to content
Larry Ullman's Book Forums

Recommended Posts

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 post
Share on other sites

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 post
Share on other sites

'<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.


Link to post
Share on other sites

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...