Joshua F Posted September 3, 2010 Share Posted September 3, 2010 I have this code.. <?php if($_SERVER['REQUEST_METHOD'] == 'POST') { mysql_query("INSERT INTO blog (date, name, desc) VALUES ('" . date("Y-m-d") . "', '". realEscape($_POST['name']) ."', '". realEscape($_POST['desc']) ."') ") or die(mysql_error()); echo "News Added."; } ?> <center><h1>Adding News</h1> <form action="news.php" method="POST"> Your News Name:<br> <input id="name" type="text" name="name" autocomplete="off" maxlength="25"><br>Your News Description: <br> <textarea name="desc" id="desc" rows="3" cols="60" maxlength="250"> </textarea><br> <input type="submit" name="submit" value="Add News"> </form> And the error is 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 'desc) VALUES ('2010-09-02', 'vcv', ' xcvxc')' at line 1 Note: vcv and xcvxc are the inputs we(I) used for a test so we(I) could get the error. Quote Link to comment https://forums.phpfreaks.com/topic/212404-add-news/ Share on other sites More sharing options...
trq Posted September 3, 2010 Share Posted September 3, 2010 desc is a reserved word. Rename it. Quote Link to comment https://forums.phpfreaks.com/topic/212404-add-news/#findComment-1106673 Share on other sites More sharing options...
Joshua F Posted September 3, 2010 Author Share Posted September 3, 2010 . Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/212404-add-news/#findComment-1106674 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.