Coly010 Posted April 9, 2012 Share Posted April 9, 2012 Ok, so I'm attempting to insert a row into a table in a mysql database. I'm using Mccodes Lite code package and my insert code does not seem to be working. Here is my code: function cr_mission() { global $ir,$c,$h,$userid; print "<h3>Adding a Mission to the game</h3><form action='admin.php?action=missionsub' method='post'> Mission Name: <input type='text' name='mname' value='' /><br /> Mission Brave: <input type='text' name='bravec' value='' /><br /> Mission Percform: <input type='text' name='percform' value='((WILL*0.8)/3.5)+(LEVEL/4)' /><font size=small>* Change the 3.5</font><br /> Mission Money: <input type='text' name='money' value='50' /><br /> Mission Group: <input type='text' name='group' value='' /><br /> Mission Info Text: <textarea rows='7' cols='75' name='itext'></textarea><br /> Mission Success Text: <textarea rows='7' cols='75' name='stext'></textarea><br /> Mission Fail Text: <textarea rows='7' cols='75' name='ftext'></textarea><br /> Mission EXP: <input type='text' name='exp' value='' /><br /> Mission Crystals: <input type='text' name='crystals' value='' /><br /> <input type='submit' value='Add Mission To Game' /></form>"; } function cr_mission_sub() { global $ir,$c,$h,$userid; if(!isset($_POST['mname']) || !isset($_POST['bravec']) || !isset($_POST['percform']) || !isset($_POST['money']) || !isset($_POST['group']) || !isset($_POST['itext']) || !isset($_POST['stext']) || !isset($_POST['ftext'])) { print "You missed one or more of the fields. Please go back and try again.<br /> <a href='admin.php?action=createmission'>> Back</a>"; $h->endpage(); exit; } { mysql_query("INSERT INTO crimes VALUES('',{$_POST['mname']},{$_POST['bravec']},{$_POST['percform']},{$_POST['money']},{$_POST['group']},{$_POST['itext']},{$_POST['stext']},{$_POST['ftext']},{$_POST['exp']},{$_POST['crystals']})",$c); print "The {$_POST['mname']} Mission was added to the game."; } } Quote Link to comment Share on other sites More sharing options...
Lithium Posted April 9, 2012 Share Posted April 9, 2012 (edited) no error thrown out? as off regular crimes table on lite it throws a #1136 - Column count doesn't match value count at row 1 Edited April 9, 2012 by Lithium Quote Link to comment Share on other sites More sharing options...
Coly010 Posted April 9, 2012 Author Share Posted April 9, 2012 Yeah, no error is shown but it doesn't insert anything into the. Database :/ Quote Link to comment Share on other sites More sharing options...
Lithium Posted April 9, 2012 Share Posted April 9, 2012 Check the fields, as you have them on the OP, it's either a missing or has a field more to count... Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted April 9, 2012 Share Posted April 9, 2012 The reason I say add that to the query is because I recently had a retarded client who is in a dispute with my because he thinks I broke his site due to that very problem...I edited his inventory table for his script because i needed to add one column and a few of his other scripts (i never touched) messed up which means the columns were not defined so better safe than sorry. Well if you added a column to the client's database which then broke other scripts regardless if you touched them or not then you was responsible for breaking those pages. Really its not a good idea to use $_POST in the query especially with McCodes depending on the version as it will not be secure. Also you dont need to use mysql_error to see an error it will automatically tell you whats incorrect. Usually in the form of Query Was.... As for the class. There is an edit for the mysql class for doing just that if you search for it. Should work with lite. Quote Link to comment Share on other sites More sharing options...
Coly010 Posted April 9, 2012 Author Share Posted April 9, 2012 Thanks everyone, i have yet to resolve this error. I will do what you have all suggested now to rectify it! Thank you for the help! Hope this helps anyone else too who may have been having a similar problem Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted April 9, 2012 Share Posted April 9, 2012 Well it is McCodes lol But really. If you undertake work you should of explained that any other script that uses the table should be checked. Yes I agree its not what you have been paid for however I see it as professional courtesy. 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.