Mike088 Posted October 12, 2008 Share Posted October 12, 2008 Hey all I am trying to use an if statement thing to assign data to a variable. Using the if statement I want to grab data from another variable which is getting its data from a html select form. Basically I want to pull two different things from the select form that are related to the one thing if you get that lol. So my code is like this (simplified): <select name="website"> <option value="100-01">Url1</option> <option value="100-02">Url2</option> <?php $url = $_POST['website']; $result = "" if ($url==100-01) $result = headache; else if ($url==100-02) $result = biggerheadache; ?> I am getting an error: Parse error: syntax error, unexpected T_IF I am not to sure if I am writing the if statement correctly or if this is actually the easiest way to go about doing what I want to do, any help much appreciated Link to comment https://forums.phpfreaks.com/topic/128079-solved-using-if-statement-to-assign-a-variable-with-data/ Share on other sites More sharing options...
DamienRoche Posted October 12, 2008 Share Posted October 12, 2008 I'm too tired to look into it too much but I can tell you that the if statement is not constructed correctly. It should be: if (argument) { //do something } else { //do something else } Hope that gives you something to do while you wait for a better response. Link to comment https://forums.phpfreaks.com/topic/128079-solved-using-if-statement-to-assign-a-variable-with-data/#findComment-663254 Share on other sites More sharing options...
Zane Posted October 12, 2008 Share Posted October 12, 2008 you have already started a topic on this....and you marked it solved don't double post...mark the other unsolved and continue. http://www.phpfreaks.com/forums/index.php/topic,220650.msg1012401.html#msg1012401 topic closed Link to comment https://forums.phpfreaks.com/topic/128079-solved-using-if-statement-to-assign-a-variable-with-data/#findComment-663255 Share on other sites More sharing options...
Recommended Posts