thefuzzyownage Posted January 5, 2009 Share Posted January 5, 2009 Well i seem to have a problem and being the new person at this and not being able to figure it out i figured i should ask someone who i know since the error coming from it doesn't give much help. <?php $mysql = mysql_connect("localhost","games29_mysql","thepassword"); if (!$mysql) { die('could not connect: ' . mysql_error()); } mysql_select_db("games29_site", $mysql); $submit = "INSERT INTO Games (gamename, category, By, Description) VALUES ('$_POST[gamename]','$_POST[category]','$_POST[by]','$_POST[Description]')"; if (!mysql_query($submit,$mysql)) { die('Error: ' . mysql_error()); } mysql_close($mysql); ?> Now i do have a form to submit the data <html> <head> <style type="text/css"> </style> </head> <body> <form name="addgame" action="addgame.php" method="post"> <table> <tr> <td>Gamename:</td> <td><input type="text" name="gamename"></td> <td>Category:</td> <td> <select name="category"> <option value="No category">No category</option> <option value="Action">Action</option> <option value="Adventure">Adventure</option> <option value="Classic/Arcade">Classic/Arcade</option> <option value="Dress up">Dress up</option> <option value="Fighting">Fighting</option> <option value="Interactions">Interactions</option> <option value="Racing">Racing</option> <option value="Puzzle">Puzzle</option> <option value="RPG/Stratgey">RPG/Stratgey</option> <option value="Sports">Sports</option> </select> </td> </tr> <tr> <td>By:</td> <td><input type="text" name="By"></td> </tr> </table> <table> <tr> <td>Description:</td> </tr> <tr> <td> <textarea name="Description" rows="10" cols="100%"></textarea> <td> </tr> <tr> <td><input type="submit" value="submit"></td> </tr> </table> </form> </body> </html> it's just a simple form so i can help automate a simple site i am making. Now once i run it, it gives me this error I used help to fill in the blanks just so you can get a idea if you need it. 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 'By, Description) VALUES ('help','No category','help','help')' at line 1 Thanks for the help. I really feel kinda stupid having to ask because i have no clue. Quote Link to comment https://forums.phpfreaks.com/topic/139598-solved-help-new-at-phpmysql/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 5, 2009 Share Posted January 5, 2009 BY is a reserved mysql keyword (as in ORDER BY). You should change the name of your column to something else. Quote Link to comment https://forums.phpfreaks.com/topic/139598-solved-help-new-at-phpmysql/#findComment-730323 Share on other sites More sharing options...
thefuzzyownage Posted January 5, 2009 Author Share Posted January 5, 2009 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/139598-solved-help-new-at-phpmysql/#findComment-730333 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.