Page 1 of 1
simple if else
Posted: Thu Feb 26, 2004 9:04 am
by cauri
Very new to php.
I have a simple if statement but I keep gatting a parse error on the echo statements and I cannot see the fault:
Code: Select all
<?php
if (is_null($row_rsFoundContacts['subway_link'])) {
echo "Subway: {$row_rsFoundContacts['subway']}";
} else {
echo "Subway: "<a href='"$row_rsFoundContacts['subway_link']"'>"$row_rsFoundContacts['subway']"</a><br />;
}
?>
Posted: Thu Feb 26, 2004 9:12 am
by twigletmac
This line is a bit foobared:
Code: Select all
echo "Subway: "<a href='"$row_rsFoundContacts['subway_link']"'>"$row_rsFoundContacts['subway']"</a><br />;
you haven't got any concenation and the quoting's a bit shady, try this:
Code: Select all
echo 'Subway: <a href="'.$row_rsFoundContacts['subway_link'].'">'.$row_rsFoundContacts['subway'].'</a><br />';
Mac
Posted: Thu Feb 26, 2004 9:12 am
by JayBird
try this out for size
Code: Select all
<?php
if (is_null($row_rsFoundContacts['subway_link'])) {
echo "Subway: {$row_rsFoundContacts['subway']}";
} else {
echo "Subway: <a href="".$row_rsFoundContacts['subway_link']."">".$row_rsFoundContacts['subway']."</a><br />";
}
?>
You need to escape your some of your literal quotes with a backslash.
Mark
Posted: Thu Feb 26, 2004 9:17 am
by Draco_03
i didn't test it bu i think this should work
Code: Select all
<?php
if (is_null($row_rsFoundContacts['subway_link'])) {
echo "Subway: {$row_rsFoundContacts['subway']}";
} else {
echo "Subway: <a href=".$row_rsFoundContacts['subway_link'].">".$row_rsFoundContacts['subway']."</a><br />";
}
?>
ahh i forgot the \" ... look at the post befor me..

Posted: Sat Feb 28, 2004 11:56 am
by cauri
thank you. It works now. I'm learning.
cauri