Jump to content


Photo

<div> tag in php code


  • Please log in to reply
9 replies to this topic

#1 skter4938

skter4938
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 20 June 2006 - 11:13 PM

Hello.

I have this code:
<?php
if ($_SESSION['error_msg']) {
foreach ($_SESSION['error_msg'] as $val) {
echo "<div id='error'>$val</div><br />";
}
unset($_SESSION['error_msg']);
}
?>

And the
<div id='error'>$val</div><br />
doesn't assign the div id to the $val.


Is there some other way I can assign the div id to $val?

#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 20 June 2006 - 11:21 PM

That code should work if you have an array in $_SESSION['error_msg']. What does it generate?
Put the following line, for debugging, before the foreach:
<?php echo '<pre>' . print_r($_SESSION['error_msg'],true) . '</pre>'; ?>
and see if $_SESSION['error_msg'] contains what you think it contains.

Ken

#3 skter4938

skter4938
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 20 June 2006 - 11:32 PM

Array
(
    [0] => Please enter in a valid email address.
)


that is what it gives me.

And the code is for a contact form. The form itself works, and the error messages are shown when somehting isn't filled in, but the <div> tags do not work :s

#4 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 20 June 2006 - 11:36 PM

try it without the

code
unset($_SESSION['error_msg']);

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#5 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 20 June 2006 - 11:40 PM

What do you mean by
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]but the <div> tags do not work[/quote]?

Do you have a test site up where we can test the form?

Ken

#6 skter4938

skter4938
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 21 June 2006 - 12:00 AM

In the echo part of the code. I assigned a div ID to $val. They do not do anything. They should make the text that $val outputs an orange color, since the css file says so.

and I have the form up on [a href=\"http://www.webtodesign.net/contact/\" target=\"_blank\"]http://www.webtodesign.net/contact/[/a]

#7 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 21 June 2006 - 12:10 AM

Try...
echo "<div id=\"error\">$val</div><br />";


#8 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 21 June 2006 - 12:10 AM

And is the CSS file actually loaded in the same script as the error messages are output?
Legend has it that reading the manual never killed anyone.
My site

#9 skter4938

skter4938
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 21 June 2006 - 01:10 AM

That it is


EDIT I got it to work. Thanks guys :D

#10 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 21 June 2006 - 04:23 AM

Please let us know what the problem was and how you fixed it. This may help others with similar problems.

Ken




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users