Jump to content

Database Query- INSERT INTO - HELP!!!


Recommended Posts

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>";
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.";
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...