tjverge Posted February 10, 2011 Share Posted February 10, 2011 <?php $opid = $_GET['opid']; $sql="Select * from `ships` WHERE `enabled` = 'Yes'"; $result = mysql_query($sql) or die (mysql_error()); echo "<form action=main.php?id=joinop.php&opid=".$opid." method=post> Ship Type: <select name = ship>"; while ($row = mysql_fetch_array($result)) { echo "<option Value=".rawurlencode($row['shiptype']).">".$row['shiptype']."</option>"; } echo "</select> <input name=submit type=submit value=Join> </form>"; if (isset($_POST['submit'])) { $stype = rawurldecode($_Post['ship']); $stime = date("G:i:s",time()); $sql="Select * from `ships` WHERE `shiptype` = '$stype'"; $result = mysql_query($sql) or die (mysql_error()); while ($row = mysql_fetch_array($result)) { $weight = $row['weight']; } echo $stype; mysql_query ("INSERT INTO `ccccomma_eve`.`userops` (`id` ,`starttime` ,`endtime` ,`shiptype` ,`weight` ,`payout` ,`active`) VALUES ('$opid', '$stime', '', '$stype', '$weight', '', 'Yes')") or die (mysql_error()); Echo "Op Joined"; } ?> The variable is empty when I echo it out, any ideas on how to make to stick? Here is just the form that is giving me trouble echo "<form action=main.php?id=joinop.php&opid=".$opid." method=post> Ship Type: <select name = ship>"; while ($row = mysql_fetch_array($result)) { echo "<option Value=".rawurlencode($row['shiptype']).">".$row['shiptype']."</option>"; } echo "</select> <input name=submit type=submit value=Join> </form>"; Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/ Share on other sites More sharing options...
cgeisler515 Posted February 10, 2011 Share Posted February 10, 2011 Try using escaped quotes in your echo statment I.E echo "<form action=\"main.php?id=joinop.php&opid=".$opid."\" method=\"post\"> Ship Type: <select name =\"ship\">"; the only other thing i could think of is that there is something wrong with the data fetched in your mysql_fetch_array($result) I would try a debug line after this statement echo out $result it should print a valid mysql result identifier Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172420 Share on other sites More sharing options...
tjverge Posted February 10, 2011 Author Share Posted February 10, 2011 the quotes didn't work, I tired echo $result; but it didn't show anything Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172422 Share on other sites More sharing options...
tjverge Posted February 10, 2011 Author Share Posted February 10, 2011 I know the sql query is good because the drop down has the right items in it Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172423 Share on other sites More sharing options...
cgeisler515 Posted February 10, 2011 Share Posted February 10, 2011 could you post your output html so i can examine it. Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172425 Share on other sites More sharing options...
tjverge Posted February 10, 2011 Author Share Posted February 10, 2011 <form action="main.php?id=joinop.php&opid=1" method="post"> Ship Type: <select name ="ship">Select * from `ships` WHERE `enabled` = 'Yes'<option Value=Test%20Ship%201>Test Ship 1</option>Select * from `ships` WHERE `enabled` = 'Yes'<option Value=Test%20Ship%202>Test Ship 2</option></select> <input name=submit type=submit value=Join> </form> Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172429 Share on other sites More sharing options...
tjverge Posted February 10, 2011 Author Share Posted February 10, 2011 my html output, code still doesn't work <form action=main.php?id=joinop.php&opid=1 method=post> Ship Type: <select name = ship><option Value=Test%20Ship%201>Test Ship 1</option><option Value=Test%20Ship%202>Test Ship 2</option></select> <input name=submit type=submit value=Join> </form> Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172438 Share on other sites More sharing options...
Pikachu2000 Posted February 10, 2011 Share Posted February 10, 2011 This should fix it. echo "<option Value=\"{$row['shiptype']}\">{$row['shiptype']}</option>"; If it doesn't, add this to the top of the script, and post the output after submitting the form. echo '<pre>'; print_r($_POST); echo '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172441 Share on other sites More sharing options...
tjverge Posted February 10, 2011 Author Share Posted February 10, 2011 did not work, here is the output Array ( [ship] => Test Ship 1 [submit] => Join ) Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172442 Share on other sites More sharing options...
kenrbnsn Posted February 10, 2011 Share Posted February 10, 2011 What do you mean by "it did not work"? You're getting the value passed into your script. Ken Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172446 Share on other sites More sharing options...
tjverge Posted February 10, 2011 Author Share Posted February 10, 2011 $stype does not have a value, it's empty when in this case it should be Test Ship 1 Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172448 Share on other sites More sharing options...
tjverge Posted February 10, 2011 Author Share Posted February 10, 2011 I found the problem and found out something new $_POST and $_Post are not the same thing! Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172451 Share on other sites More sharing options...
kenrbnsn Posted February 10, 2011 Share Posted February 10, 2011 This line <?php $stype = rawurldecode($_Post['ship']); ?> should be <?php $stype = $_POST['ship']; ?> $_Post != $_POST and you don't need the rawurldecode() function. Ken Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172454 Share on other sites More sharing options...
Pikachu2000 Posted February 10, 2011 Share Posted February 10, 2011 And note that attributes in html tags should be quoted. <select name="ship">, etc. Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172455 Share on other sites More sharing options...
tjverge Posted February 10, 2011 Author Share Posted February 10, 2011 Thank you all for the help, I'm getting there I'm leaning so much Quote Link to comment https://forums.phpfreaks.com/topic/227298-not-passing-value/#findComment-1172456 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.