jedigunz Posted August 5, 2013 Posted August 5, 2013 i came across this mod,. http://makewebgames.io/showthread.php/25591-mccode-v2-Editing-Organised-Crimes so when doing this mod i realized my CREATE OC had no existence in the file,. so ive had to make one from scratch,. but have come across an error,. ::::HERES THE SCRIPT:::: case 'createoc': create_oc(); break; case 'createocsub': create_oc_submit(); break; function create_oc() { global $db,$ir, $c; if($ir['user_level'] != 2) { die("403"); } print "Create an OC.<br /> <form action='staff_gangs.php?action=createocsub' method='post'> Name the OC: <input type='text' name='ocNAME' /><br> Minimum users for crime: <input type='text' name='ocUSERS' /><br> Beginning Text: <input type='text' name='ocSTARTTEXT' /><br> Success Text: <input type='text' name='ocSUCCTEXT' /><br> Failure Text <input type='text' name='ocFAILTEXT' /><br> Minimum Possible Money <input type='text' name='ocMINMONEY' /><br> Maximum Possible Money <input type='text' name='ocMAXMONEY' /><br> <br /> <input type='submit' value='Create OC' /></form>"; } function create_oc_submit() { global $db,$ir,$c,$userid; if($ir['user_level'] != 2) { die("403"); } $ocNAME=abs((int) $_POST['ocNAME']); $ocUSERS=abs((int) $_POST['ocUSERS']); $ocSTARTTEXT=abs((int) $_POST['ocSTARTTEXT']); $ocSUCCTEXT=abs((int) $_POST['ocSUCCTEXT']); $ocFAILTEXT=abs((int) $_POST['ocFAILTEXT']); $ocMINMONEY=abs((int) $_POST['ocMINMONEY']); $ocMAXMONEY=abs((int) $_POST['ocMAXMONEY']); $db->query("INSERT INTO orgcrimes (ocNAME, ocUSERS, ocSTARTTEXT, ocSUCCTEXT, ocFAILTEXT, ocMINMONEY, ocMAXMONEY, WHERE ocID='{$_POST['ocID']}' )"); print "Organized Crime created!"; stafflog_add("Created OC"); } -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ::::HERE'S THE ERROR:::: QUERY ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE ocID='')' at line 2 Query was INSERT INTO orgcrimes (ocNAME, ocUSERS, ocSTARTTEXT, ocSUCCTEXT, ocFAILTEXT, ocMINMONEY, ocMAXMONEY, WHERE ocID='') ::::LINE IT REFERS TO:::: $db->query("INSERT INTO orgcrimes (ocNAME, ocUSERS, ocSTARTTEXT, ocSUCCTEXT, ocFAILTEXT, ocMINMONEY, ocMAXMONEY, WHERE ocID='{$_POST['ocID']}')"); -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- WHERE ocID='{$_POST['ocID']}' how can this be wrote correctly ?? and isit even correct ?? could anyone give us a hand ?? Quote
Jigsaw Posted August 5, 2013 Posted August 5, 2013 (edited) $db->query("INSERT INTO orgcrimes (ocNAME, ocUSERS, onSTARTTEXT, ocSUCCTEXT, ocFAILTEXT, ocMINMONEY,ocMAXMONEY) VALUES ('{$_POST['ocNAME']}', '{$_POST['ocUSERS']}' , '{$_POST['ocSTARTTEXT']}', '{$_POST['ocSUCCTEXT']}', '{$_POST['ocFAILTEXT']}','{$_POST['ocMINMONEY']},'{$_POST['ocMAXMONEY']}')"); Edited August 5, 2013 by Jigsaw Quote
Script47 Posted August 5, 2013 Posted August 5, 2013 To make you understand a bit more why the query failed, the MySQL "Insert" syntax does not support the "where" clause, so that query failed as it had a "where" clause in it. Quote
jedigunz Posted August 5, 2013 Author Posted August 5, 2013 (edited) oh okay thanks Script47,. and jigsaw i added that in place of the last query but ended up getting this error QUERY ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '30000')' at line 1 Query was INSERT INTO orgcrimes (ocNAME, ocUSERS, onSTARTTEXT, ocSUCCTEXT, ocFAILTEXT, ocMINMONEY,ocMAXMONEY) VALUES ('Armed Robbery', '2' , 'B', 'S', 'F','10000,'30000') personally i cant even see the problem in the script now,. Edited August 5, 2013 by jedigunz opinion Quote
jedigunz Posted August 5, 2013 Author Posted August 5, 2013 i spotted a ' missing from it,.. still got this back though QUERY ERROR: Unknown column 'onSTARTTEXT' in 'field list' Query was INSERT INTO orgcrimes (ocNAME, ocUSERS, onSTARTTEXT, ocSUCCTEXT, ocFAILTEXT, ocMINMONEY, ocMAXMONEY) VALUES ('Armed Robbery', '2' , 'B', 'S', 'F', '10000', '30000') gonna have to refer to the database Quote
jedigunz Posted August 5, 2013 Author Posted August 5, 2013 oops,. flew by it,.. onSTARTTEXT ,. meant to be ocSTARTTEXT ,.. thanks for your help Jigsaw & Script47,. Edited Query and Working :: $db->query("INSERT INTO orgcrimes (ocNAME, ocUSERS, ocSTARTTEXT, ocSUCCTEXT, ocFAILTEXT, ocMINMONEY, ocMAXMONEY) VALUES ('{$_POST['ocNAME']}', '{$_POST['ocUSERS']}', '{$_POST['ocSTARTTEXT']}', '{$_POST['ocSUCCTEXT']}', '{$_POST['ocFAILTEXT']}', '{$_POST['ocMINMONEY']}', '{$_POST['ocMAXMONEY']}')"); Quote
Script47 Posted August 5, 2013 Posted August 5, 2013 (edited) oh okay thanks Script47,. thanks for your help Script47,. No problem. Glad I could help. :) Side note: My 200th post, Yay me! :p Edited August 5, 2013 by Script47 Quote
jedigunz Posted August 5, 2013 Author Posted August 5, 2013 wow stackin them posts script :p over quadruple mine Quote
KyleMassacre Posted August 5, 2013 Posted August 5, 2013 ummm I see your using abs((int)) on text fields. you should look into using another function like $db->escape() or something along that nature Quote
Script47 Posted August 6, 2013 Posted August 6, 2013 wow stackin them posts script :p over quadruple mine Thanks mate, it was your thread which got me to it. ;) Quote
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.