Jump to content

[SOLVED] Help? New at Php/mysql


thefuzzyownage

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/139598-solved-help-new-at-phpmysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.