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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.