need help with php error

gamewars

New Member
Messages
16
Reaction score
1
Points
0
Im new to php and I dont realy know a lot I have been stuck trying to fix this problem for a long time.

here is the error code.


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 'and Date, Number of rounds, Number of players) VALUES ('guns','lipsmacky','11:15' at line 1


here is the html code.


<html>
<head>
<style type="text/css">
body
{
background-color:#73a65a;
}
div.banner
{
width:450px;
height:80px;
background:url('http://gamewars.x10hosting.com/images/xbox360banner.jpg') no-repeat;
border:0px solid black;
margin:0px 125px;
}
div.form
{
width:500px;
height:250px;
border:0px solid black;
margin:80px 250px;
}
</style>
</head>
<body>
<div class="banner">
</div>
<div class="form">
<form action="postwarsxbox360.php" method="post">
Game:
<input type="text" name="firstname" />
<br />
Gamertag:
<input type="text" name="lastname" />
<br>
Time and date 00:00 0/0/09:
<input type="text" name="quantity" />
<br>
<h4>Number Of Rounds</h4>
<select name="items">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="more">more</option>
</select>
<br>
<h4>Number Of Players</h4>
<select name="players">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="more">more</option>
</select>
<br>
<input type="submit" />
</form>
<br>
<a href="http://gamewars.x10hosting.com">
<img border="0" src="http://gamewars.x10hosting.com/images/gamewarshomebutton.jpg" width="100" height="25">
</a>
</div>
</body>
</html>


here is the php code.


<?php
$con = mysql_connect("localhost", "gamewars_gamewars","xxxxxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("gamewars_xbox360postedwars", $con);
$sql="INSERT INTO xbox360 (Game, Gamertag, Time and Date, Number of rounds, Number of players)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[quantity]','$_POST[items]','$_POST[players]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
mysql_close($con)
?>



to get the error click on this link. http://gamewars.x10hosting.com/postwarsxbox360.html

I dont have a lot so for exchange for the help ill make any kind of graphics and code them.
 
Last edited:

z_killemall

New Member
Messages
47
Reaction score
0
Points
0
You probably got a problem with spaces in fields like Time and Date, Number of rounds or Number of players. If there nothing else using these fields, change them to timedate, rounds and players, for example. Otherwise you can try single quoting the fields in that line, to make MySQL notice that it's a single field.
 
Top