Liru Posted December 1, 2010 Share Posted December 1, 2010 My code: <?php if ($_REQUEST['poll_question']){ include 'database_info.php'; //Seeing how many options were filled in switch ($_REQUEST['poll_question']){ case ($_REQUEST['option_4'] != ''): $options = $_REQUEST['option_1'] ." | ".$_REQUEST['option_2'] ." | ".$_REQUEST['option_3'] ." | ".$_REQUEST['option_4']; break; case ($_REQUEST['option_3'] !=''): $options = $_REQUEST['option_1'] ." | ".$_REQUEST['option_2'] ." | ".$_REQUEST['option_3']; break; case ($_REQUEST['option_2'] !=''): $options = $_REQUEST['option_1'] ." | ".$_REQUEST['option_2']; break; case ($_REQUEST['option_1'] !=''): die("The poll needs more then one option."); break; mysql_query = ("INSERT INTO poll VALUES ('','".mysql_real_escape_string($_REQUEST['poll_question']."', '".mysql_real_escape_string($options)."', ".time().")"); echo "The poll has been created."; }else{ <form name="poll_submit" action="<?php $_SERVER[php_SELF];?>" method="POST"> Poll Question: <input type="text" name="poll_question"> <br /> Poll Options: <br /> <input type="text" name="option_1"> <br /> <input type="text" name="option_2"> <br /> <input type="text" name="option_3"> <br /> <input type="text" name="option_4"> <br /> <input type="submit"> </form> } ?> What did I do wrong? I get this error. Parse error: syntax error, unexpected '=' in /home/moviefli/spambb.com/index.php on line 83 Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted December 1, 2010 Share Posted December 1, 2010 mysql_query("INSERT not mysql_query = ("INSERT switch() statement is missing a closing curly brace } For the last } else {, you try to send html to the browser without a closing ?> tag. Fixing the above will necessitate opening <?php tag before the very last closing curly brace Don't use $_SERVER['PHP_SELF'] as a form action. It presents a known XSS vulnerability. Use action="" instead. There might be others, but I *think* that's all of them. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.