Derleek Posted May 30, 2008 Share Posted May 30, 2008 Ok, so i posted this in the MySQL help section but i'm not sure if i should post it here or there. I set up a script to store 10 items that where selected by a user w/ drop down menu's. This script is supposed to take each of the 10 selected values along with several user oriented variables into a database called 'benchracers'. Everything seemed to be working fine, until i went to output the data stored. The only thing that has an output value is "ID". so can anyone figure out why the ONLY thing I am able to get an output value to is 'ID'. here is the code: Code: if(isset($_POST)) { dbconnect('thethrgu_moto'); foreach ($choices as $n => $choice) { if ($choice == 'null') { error('you did not completely fill out your top ten!!!'); } } if (count(array_unique($choices)) != 10) { error('you had some duplicate riders, please make sure you do not enter a rider more than once!'); } else { $race_id = 3; $paid = 1; $pick_id=1; $sql = "SELECT COUNT(*) FROM benchRacers WHERE id = $id && race_id = $race_id"; $result = mysql_query($sql); if (!$result) { echo mysql_error(); } if (@mysql_result($result,0,0)>0) { echo "You have already entered your data for this race, would you like to re-do it?"; } else { for($i=0;$i<10;$i++) { $sql = "INSERT INTO benchracers (id, pick_id, racer_id, race_id, paid) VALUES ($id,$pick_id,$choices[$i],$race_id,$paid)"; echo $sql; mysql_query($sql) or die(mysql_error()); $pick_id++; } $query = "SELECT * FROM benchracers"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result, MYSQL_ASSOC)){ echo "id: ".$row['id']." - Race_id: ".$row['race_id']." - Racer_id: ".$row['racer_id']." - Pick_id: ".$row['pick_id']."<br>"; } } } } and the table create: Code: $benchracers = "CREATE TABLE benchRacers( id INT, pick_ID INT, racer_ID INT, race_ID INT, paid INT)"; mysql_query($query) or die(mysql_error()); It is entirely possible (i suppose) that the way i am retrieving the data is not valid, and is getting all funked up. I don't know... please pick at my code if you so chose, i love figuring out new and better ways to get things done Quote Link to comment https://forums.phpfreaks.com/topic/107902-solved-confused/ Share on other sites More sharing options...
Gighalen Posted May 30, 2008 Share Posted May 30, 2008 When you export the database, are the variables in there? Quote Link to comment https://forums.phpfreaks.com/topic/107902-solved-confused/#findComment-553111 Share on other sites More sharing options...
Gighalen Posted May 30, 2008 Share Posted May 30, 2008 Where are you declaring the variable $choices? Quote Link to comment https://forums.phpfreaks.com/topic/107902-solved-confused/#findComment-553113 Share on other sites More sharing options...
Derleek Posted May 30, 2008 Author Share Posted May 30, 2008 The only variable that shows up is "id" $choices is defined by the user with the drop down menu Quote Link to comment https://forums.phpfreaks.com/topic/107902-solved-confused/#findComment-553116 Share on other sites More sharing options...
Gighalen Posted May 30, 2008 Share Posted May 30, 2008 It's not getting the $choice variables. try doing a $choice = $_POST['choice']; or something like that Quote Link to comment https://forums.phpfreaks.com/topic/107902-solved-confused/#findComment-553119 Share on other sites More sharing options...
Derleek Posted May 30, 2008 Author Share Posted May 30, 2008 there isn't a problem with the variables not being set, when i output $SQL everything is set as it should be Quote Link to comment https://forums.phpfreaks.com/topic/107902-solved-confused/#findComment-553136 Share on other sites More sharing options...
Derleek Posted May 30, 2008 Author Share Posted May 30, 2008 well php outsmarted me again... for the variables not showing up i used 'racer_id' instead of racer_ID... bah took me way too long to catch that... Quote Link to comment https://forums.phpfreaks.com/topic/107902-solved-confused/#findComment-553146 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.