Delete-please Posted January 21, 2009 Posted January 21, 2009 Hi i wanted to add an event to someone when they have received a warning here is the warnings page <?php include 'globals.php'; $is=$db->query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid") or die(mysql_error()); $ir=mysql_fetch_array($is); if($ir['user_level'] < 2) { die("Staff Only!"); } switch($_GET['action']) { case 'add': addwarning(); break; case 'addsub': addwarning2(); break; case 'del': deletewarning(); break; case 'edit': editwarning(); break; case 'edit2': editwarning2(); break; default: index(); break; } function index() { global $ir,$h,$db,$userid; print "<h3>Viewing Warnings For ID: <a href=viewuser.php?u={$_GET['user']}>{$_GET['user']}</a></h3> "; $q=$db->query("SELECT w.*,u.* FROM warnings w LEFT JOIN users u ON w.warner=u.userid WHERE w.user={$_GET['user']} ORDER BY w.time DESC"); print "<center><font color=red><h4>Total Warnings: ".mysql_num_rows($q)." </h4> [<a href=warnings.php?action=add&userid={$_GET['user']}>Add Warning</a>] <table width=90% border=1 align=center><tr><tr style='background: light green'><td>Warned By:</td><td width=40%>Reason</td><td>Date</td><td>Links</td></tr>"; while($r=mysql_fetch_array($q)) { $warned=date('F j, Y, g:i:s a',$r['time']); print "<tr><td><a href=viewuser.php?u={$r['userid']}>{$r['username']}</a></td><td>{$r['warnedfor']}</td><td>$warned</td><td>"; if($ir['userid'] == 1) { print "[<a href=warnings.php?action=del&ID={$r['id']}>Remove</a>] "; } if($ir['warner'] == $userid || $userid == 1) { print "[<a href=warnings.php?action=edit&ID={$r['id']}>Edit</a>]"; } print "</td></tr>"; }} function addwarning() { global $ir,$h,$db,$userid; print "<form action=warnings.php?action=addsub method=post> <input style='visibility: hidden' name=user value={$_GET['userid']}> Reason: <textarea rows=7 cols=30 name=reason></textarea> <input type=submit value='Add warning'></form>"; } function addwarning2() { global $ir,$h,$db,$userid; $_POST['user']=($_POST['user']); $_POST['reason']=($_POST['reason']); $db->query("INSERT INTO warnings VALUES ('','{$_POST['user']}','{$_POST['reason']}','$userid',unix_timestamp())"); event_add($r['userid'], "<font color=red>You have recieved a warning for the reason {$_POST['reason']} if you continue your ways further action will be taken. Sniper Wars staff.", $c); $checkfed=$db->query("SELECT * FROM warnings WHERE user='{$_POST['user']}'"); if(mysql_num_rows($checkfed) > 5) { $db->query("UPDATE users SET fedjail=1 WHERE userid='{$_POST['user']}'"); $db->query("INSERT INTO fedjail VALUES('','{$_POST['user']}','300','$userid','Reached 6 warnings in game. Account jailed.')"); } print "Warning Added! [*]<a href=viewuser.php?u={$_POST['user']}>Back to users profile</a>"; } function deletewarning() { global $ir,$h,$db,$userid; if($ir['userid'] != 1) { die("Owner Only");} $db->query("DELETE FROM warnings WHERE id={$_GET['ID']}"); print "Warning Deleted"; } function editwarning() { global $ir,$h,$db,$userid; $target=$_GET['ID']; $edit=$db->query("SELECT * FROM warnings WHERE id='$target'"); while($r=mysql_fetch_array($edit)) { if($r['warner'] != $userid || $userid != 1) { die("You never set this warning, therefore cannot edit it"); } print "<h3>Edit Warning</h3> <form action=warnings.php?action=edit2 method=post> <input style='visibility: hidden;' name=id value=$target> <textarea rows=7 cols=30 name=reason>{$r['warnedfor']}</textarea> <input type=submit value='Edit Warning'></form>"; } } function editwarning2() { global $ir,$h,$db,$userid; $db->query("UPDATE warnings SET warnedfor={$_POST['reason']} WHERE id={$_POST['id']}"); print "Warning Updated. [*]<a href=index.php>Home</a>"; } ?> and here is the error i get 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 'UNIX_TIMESTAMP(),0,'You have recieved a warning for the reason t' at line 1 Query was INSERT INTO events VALUES('',,UNIX_TIMESTAMP(),0,'You have recieved a warning for the reason test if you continue your ways further action will be taken. Sniper Wars staff.') and here is the event add incase you missed it event_add($r['userid'], "<font color=red>You have recieved a warning for the reason {$_POST['reason']} if you continue your ways further action will be taken. Sniper Wars staff.", $c); Quote
Haunted Dawg Posted January 21, 2009 Posted January 21, 2009 Re: Event add problem I really do not want to help you but i like to help so here try this. event_add(abs(@intval($_POST['user'])), '<font color="red">You have recieved a warning for the reason '.$_POST['reason'].'. If you continue your way\'s further action will be taken. Your game name staff.'); Quote
gurpreet Posted January 21, 2009 Posted January 21, 2009 Re: Event add problem Where did you add the query? I'm a noob at this, but I think you are missing a 'texthere', as in a field/column entry. As in say you have 10 columns in your DB and the query inserts 11..Something like that. OR Try this: event_add($ir['userid'], "<font color=red>You have recieved a warning for the reason {$_POST['reason']} if you continue your ways further action will be taken. Sniper Wars staff.", $c); Quote
Haunted Dawg Posted January 21, 2009 Posted January 21, 2009 Re: Event add problem Why would you want to send the event to your self? That sound's pathetic.. -.- Quote
gurpreet Posted January 21, 2009 Posted January 21, 2009 Re: Event add problem Well it's not my fault I made a mistake Mr. Perfect... :roll: Quote
Delete-please Posted January 21, 2009 Author Posted January 21, 2009 Re: Event add problem Thanks kyle,, and thanks for trying gurpreet :-P Quote
Lithium Posted January 21, 2009 Posted January 21, 2009 Re: Event add problem by any chance all other events work fine? Because that seems a problem with the event_add() function 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.