supermerc Posted August 21, 2007 Share Posted August 21, 2007 Hey, I have this code: <?php require("config.php"); require("functions.php"); session_start(); if (isset($_POST['addhit'])) { $name = mysql_escape_string($_POST['owname']); $reason = mysql_escape_string($_POST['reason']); $sql = "INSERT INTO hitlist(outwarname, reason, by) VALUES ('{$name}', '{$reason}', '{$_SESSION[s_username]}')"; // Execute Query $qry = mysql_query($sql) or die("MySQL Error: <br /> {$sql} <br />". mysql_error()); header("Location: http://zimbob.outwar.com/hitlist.php?hitname='.$name.'&hitreason='.$reason'"); } ?> and im getting this error MySQL Error: INSERT INTO hitlist(outwarname, reason, by) VALUES ('test', 'test', 'ServeD') 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 'by) VALUES ('test', 'test', 'ServeD')' at line 1 Does anyone know whats wrong? Link to comment https://forums.phpfreaks.com/topic/66012-php-error/ Share on other sites More sharing options...
trq Posted August 21, 2007 Share Posted August 21, 2007 I do believe by is a reserved word, try... $sql = "INSERT INTO hitlist(outwarname, reason, `by`) VALUES ('{$name}', '{$reason}', '{$_SESSION[s_username]}')"; Link to comment https://forums.phpfreaks.com/topic/66012-php-error/#findComment-330105 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.