Dark-Hawk Posted June 1, 2009 Share Posted June 1, 2009 Alright, here is part of a script I'm working on that simply wont post or edit a number of fields to the DB. It's not returning any errors, but simply put it's not doing anything at all and I cannot see why. I basically reused another part of the application here and just changed the fields as it's all the same. Other one works fine .. this one, not so much. So here's part of the script that's applicable, I can post the entire thing if wanted: include "header.php"; include "menu.php"; // add $range_time = $_GET['range_time']; // Time range IE: 4pm to 5pm $range_days = $_GET['range_days']; // Range of days in the month to display $amount = $_GET['amount']; // this is the amount of sign ups per time slot $duration = $_GET['duration']; // duration of meetings $group = $_GET['group']; // group name $month = $_GET['month']; // numerical representation of month for group if ($post == "add") { $range_time = $hour1 . ':' . $minute1 . '-' . $hour2 . ':' . $minute2; $range_days = $day1 . "-" . $day2; if ( ($range_time) && ($range_days) && ($amount) && ($duration) && ($group) && ($month) ) { mysql_query(sprintf("INSERT into groups (range.time, range.days, amount, duration, group, month, id) VALUES ('%s', '%s', '%d', '%d', '%s', '%d', '%d')", $_POST['range_time'], $_POST['range_days'], $_POST['amount'], $_POST['duration'], $_POST['group'], $_POST['month'], '')) or die('SQL Error : ' . mysql_error()); $error = mysql_error(); echo $error; echo "<div align=center><b>Added $group</b></div><br><br>"; } } <form method="post" action="<? echo $PHP_SELF; ?>"> <table cellpadding=3 cellspacing=0 border=0 width="100%"> <tr> <th></th> <th>Time Range</th> <th>Range of Days</th> <th>Sign Ups per Time</th> <th>Duration of Meeting</th> <th>Group</th> <th>Month</th> <th>ID</th> <th></th> </tr> <? if ($month_search == "all") { $mon = "month='1' OR month='2' OR month='3' OR month='4' OR month='5' OR month='6' OR month='7' OR month='8' OR month='9' OR month='10' OR month='11' OR month='12' "; } else { $mon = "month='$month_search' "; } $sort = "ORDER BY $sort $order"; if ($group) { $group = "WHERE group LIKE '%$group%' AND "; } else { $group = "WHERE "; } $query = "SELECT * FROM groups ".$group.$mon.$sort; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { $bgcolor = ($bgcolor == "#F0F0F0"?"#DFDFDF":"#F0F0F0"); ?> <tr bgcolor="<? echo $bgcolor; ?>"> <td align=center><a href="<? echo $PHP_SELF."?edit=".$row['id']; ?>" class="blue">Edit</a></td> <td align=center><? echo $row['range.time']; ?></td> <td align=center><? echo $row['range.days']; ?></td> <td align=center><? echo $row['amount']; ?></td> <td align=center><? echo $row['duration']; ?></td> <td align=center><? echo $row['group']; ?></td> <td align=center><? echo $row['month']; ?></td> <td align=center><? echo $row['id']; ?></td> <td align=center><input type="checkbox" name="del[]" value="<? echo $row['id']; ?>" class="checkbox"></td> </tr> <? } mysql_free_result($result); ?> <tr> <td colspan=7 align=right> <input type="hidden" value="del" name="post"> <input type="submit" value="Delete Checked"> </form> </td> </tr> </table> <? } ?> <br><br> <form method="post" action="<? echo $PHP_SELF; ?>"> <table cellpadding=3 cellspacing=0 border=0 width="100%"> <tr><td colspan=4><b>Add Group</b></td></tr> <tr><td class="dots" colspan=4></td></tr> <tr> <td><b>Time Range:</b></td> <td><b>Day Range:</b></td> <td><b>Sign Ups:</b></td> <td><b>Duration:</b></td> <td><b>Group Name:</b></td> <td><b>Month:</b></td> </tr> <tr> <td><select name="edithour1"> <? for($x = 1; $x <= 12; $x++) { echo "<option value='$x'>$x</option>"; } ?> </select><b>:</b> <select name="editminute1"><? for($a=0; $a < 6; $a++){ for($b=0; $b < 10; $b++){ echo "<option value='$a$b'>$a$b</option>"; } }?> </select> <b>-</b> <select name="edithour2"> <? for($z = 1; $z <= 12; $z++) { echo "<option value='$z'>$z</option>"; } ?> </select><b>:</b> <select name="editminute2"> <?for($a=0; $a < 6; $a++){ for($b=0; $b < 10; $b++){ echo "<option value='$a$b'>$a$b</option>"; } }?> </select> </td> <td> <select name="editday1"> <option selected="selected" value="sun">Sunday</option> <option value="mon">Monday</option> <option value="tue">Tuesday</option> <option value="wed">Wednesday</option> <option value="thu">Thursday</option> <option value="fri">Friday</option> <option value="sat">Saturday</option> </select> <b>-</b> <select name="editday2"> <option selected="selected" value="sun">Sunday</option> <option value="mon">Monday</option> <option value="tue">Tuesday</option> <option value="wed">Wednesday</option> <option value="thu">Thursday</option> <option value="fri">Friday</option> <option value="sat">Saturday</option> </select> </td> <td> <select name="edit_amount"> <?php for($x = 1; $x <= 10; $x++) { echo "<option value='$x'>$x</option>"; } ?> </select> </td> <td> <select name="edit_duration"> <?php for ($y = 5; $y <= 60; $y += 5) { echo "<option value='$y'>$y</option>"; } ?> </select> </td> <td> <input type="text" name="edit_group" value="<?php echo $row['group']; ?>" size=20> </td> <td> <?php $month_names = array( 'Jan'=> '', 'Feb'=>'', 'Mar'=>'','Apr'=>'', 'May'=> '', 'Jun'=>'', 'Jul'=>'','Aug'=>'', 'Sep'=> '', 'Oct'=>'', 'Nov'=>'', 'Dec'=>''); $month_names[date('M')] = ' selected'; echo '<select name="month"> '; foreach($month_names as $month=> $selected){ echo '<option value="'.$month.'"'.$selected.'> '.$month.'</option>'; } echo '</select> '; ?> </td> </tr> <tr> <td colspan=4 align=right> <input type="hidden" value="add" name="post"> <input type="submit" value="Add Group"> </td> </tr> </table> </form> config file is included in the header. This is the SQL structure: CREATE TABLE `groups` ( `range.time` varchar(128) NOT NULL default '', `duration` varchar(128) NOT NULL default '', `amount` varchar(128) NOT NULL default '', `group` varchar(128) NOT NULL default '', `month` varchar(12) NOT NULL default '0', `range.days` varchar(48) NOT NULL default '', `id` int(255) NOT NULL auto_increment, PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=2 ; Link to comment https://forums.phpfreaks.com/topic/160486-not-posting-to-db/ Share on other sites More sharing options...
Dark-Hawk Posted June 3, 2009 Author Share Posted June 3, 2009 No one has any ideas..? Link to comment https://forums.phpfreaks.com/topic/160486-not-posting-to-db/#findComment-848517 Share on other sites More sharing options...
trq Posted June 3, 2009 Share Posted June 3, 2009 Obviously you have display errors switched off as your code is riddled with parse errors. Set it on and you might find some of them. Link to comment https://forums.phpfreaks.com/topic/160486-not-posting-to-db/#findComment-848520 Share on other sites More sharing options...
PFMaBiSmAd Posted June 3, 2009 Share Posted June 3, 2009 We don't have access to all your code and relevant files (and no, we don't want you to post all of it), we don't have access to your server, and we don't have access to your database. The only one here that can actually troubleshoot what your code is doing on your server with your database is you. So, what have you done to pin down what it is doing? What execution path is the logic taking? What are the values being tested in the conditional statements? Are the forms being display correctly? The forms in the posted code use method="post" but the posted code using $_GET variables? Are the $_GET variables coming from the form(s) on that page or do you have a link that requests the posted code that does have those $_GET variables? Link to comment https://forums.phpfreaks.com/topic/160486-not-posting-to-db/#findComment-848535 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.