if ($Quien = "2") { $Quien = "Webmaster" }
if ($Quien = "1") { $Quien = "Publicidad" }
if ($Quien = "3") { $Quien = "Otro" }
Is that code correct?
the numbers and the vars. are getted from a html form (a 3 option combo box)
but im gettin gthis error…
Parse error: parse error, unexpected ‘}’ in <URL> on line 38
Any ideas?
system
January 22, 2003, 4:31pm
2
dont forget the “;”
the code should look like thsi:
if ($Quien = "2")
{
$Quien = "Webmaster";
}
if ($Quien = "1")
{
$Quien = "Publicidad";
}
if ($Quien = "3")
{
$Quien = "Otro";
}
system
January 22, 2003, 4:31pm
3
and you could probably use an array to make it a little neater.
system
January 22, 2003, 4:32pm
4
o my god… the same prob again!?
lol!
lemme check… thanks jubba gonna put a note on my monitor “dont forget the ; !!!”
system
January 22, 2003, 4:34pm
6
Well you are checking to see if a variable equals something, so wouldn’t it be…
if ($Quien == "2") {
$Quien = "Webmaster";
}
if ($Quien == "1") {
$Quien = "Publicidad";
}
if ($Quien == "3") {
$Quien = "Otro";
}
Because == checks to see if that variable equals something.
system
January 22, 2003, 4:34pm
7
yeah, everything needs to have a ;
The only things that don’t are 'if statements, loops of some kind (while, for, do) or lines that only have a } or { "
system
January 22, 2003, 4:35pm
8
I think it will work either way. The more correct way would be ==
system
January 22, 2003, 4:36pm
9
Oh… I know in Flash and Javascript = doesn’t work, you need == , so I just do it in PHP that way naturally, never tried with one =.
system
January 22, 2003, 4:44pm
10
actually, now that you mention it, neither have I. Everything I have ever used PHP for has been returning a Bealoon value, TRUE or FALSE. So I always use !=
Oh, and for the array, try this:
<?
$Quien = $_POST['Quien'];
$myArray = array ("Webmaster", "Publicidad", "Otro");
$Quien = $Quien - 1;
print "$myArray[$Quien]";
?>
system
January 22, 2003, 4:45pm
11
Because Arrays are ZERO based, you have to subract one from the variable Quien, in order for the array to work. Instead of 1,2,3 the values for the array are 0,1,2
system
January 22, 2003, 4:46pm
12
if ($Quien == "Webmaster") {
mail("chidos@hotmail.com","$subject","$message","From: $Name <$Email>");
}
if ($Quien == "Publicidad") {
mail($toemail,"$subject","$message","From: $Name <$Email>");
}
if ($Quien == "Otro") {
mail($toemail,"$subject","$message","From: $Name <$Email>");
}
Now the other code seems to be working now (the if)
but when it gets here,no matter which option is selected it always sends the email to Webmaster… you know what could causing it?
To get here it goes tru a check if the fields are correct if the email is correct… etc…
should i put all the code?
system
January 22, 2003, 4:48pm
13
post the whole thing. it may help
system
January 22, 2003, 4:51pm
14
if ($Quien = "2")
{
$Quien = "Webmaster";
}
if ($Quien == "1")
{
$Quien = "Publicidad";
}
if ($Quien == "3")
{
$Quien = "Otro";
}
if($submitform) {
// check required fields
$dcheck = explode(",",$require);
while(list($check) = each($dcheck)) {
if(!$$dcheck[$check]) {
$error .= "Falta $dcheck[$check]<br>";
}
}
// check email address
if ((!ereg(".+\@.+\..+", $Email)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $Email))){
$error .= "Email Invalido<br>";}
// display errors
if($error) {
?>
<b>Error</b><br>
<?php echo $error; ?><br>
<a href="#" onClick="history.go(-1)">Intenta de nuevo</a>
<?php
}
else
{
$browser = $HTTP_USER_AGENT;
$ip = $REMOTE_ADDR;
// format message
$message = "Mensaje desde Contactanos:
E-Mail Dirigido a $Quien
Nombre: $Name
Email: $Email
Telefono: $Tel
Mensaje: $Comments
-----------------------------
Browser: $browser
User IP: $ip";
// send mail and print success message
if ($Quien == "Webmaster") {
mail("chidos@hotmail.com","$subject","$message","From: $Name <$Email>");
}
if ($Quien == "Publicidad") {
mail($toemail,"$subject","$message","From: $Name <$Email>");
}
if ($Quien == "Otro") {
mail($toemail,"$subject","$message","From: $Name <$Email>");
}
//hurrah i think it stands
if($hurrah) {
if($autoresponse == "yes") {
$autosubject = stripslashes($autosubject);
$automessage = stripslashes($automessage);
mail($Email,"$autosubject","$automessage","From: $recipientname <$recipientemail>");
}
echo "$thanks";
}
}
}
else {
?>
system
January 22, 2003, 4:52pm
15
theres more code but its for the FORM and some vars that you set on top of the file…
you need that to?
if so, ill attach the file
system
January 22, 2003, 4:54pm
16
You used == on “1” and “3”, but not on “2”
system
January 22, 2003, 4:54pm
17
nah, in your first if statement, change the = to ==. I think it may be causing the problem. I think the one = is setting the variable to 2 and therefore it always will send to webmaster.
system
January 22, 2003, 5:02pm
18
well the if for webmaster is working…
but when i try and select another option from the box, it simply dosent send the email.
also… i think the Autoresponse at the bottom of that dosent seem to work…
and i dont where the $hurrah var comes from…
system
January 22, 2003, 5:06pm
19
did you change the = to == tho? that could be causing the whole problem…
Also, I have no idea what that is… if you don’t need the autoresponce thing I would take it out…
I have to go to class now… good luck with everything
system
January 22, 2003, 5:09pm
20
Thanks for the help JUBBA!
:D:D:D
i see if i can figure it out.
:trout: