+ Reply to Thread
Results 1 to 3 of 3

Thread: need help with php error

  1. #1
    gamewars is offline x10Hosting Member gamewars is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    16

    need help with php error

    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/image...homebutton.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 by gamewars; 08-27-2009 at 08:34 AM.

  2. #2
    z_killemall's Avatar
    z_killemall is offline x10Hosting Member z_killemall is an unknown quantity at this point
    Join Date
    Nov 2007
    Posts
    47

    Re: need help with php error

    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.

  3. #3
    gamewars is offline x10Hosting Member gamewars is an unknown quantity at this point
    Join Date
    Jul 2009
    Posts
    16

    Re: need help with php error

    thanks it works now
    Last edited by gamewars; 08-27-2009 at 09:58 AM.

+ Reply to Thread

Similar Threads

  1. Replies: 4
    Last Post: 03-15-2009, 01:51 PM
  2. Error headers with php.
    By Tarzan in forum Programming Help
    Replies: 5
    Last Post: 08-06-2008, 11:07 AM
  3. Replies: 1
    Last Post: 05-03-2008, 03:42 AM
  4. "PHP Startup: Invalid Library" - Interesting error
    By javaguy78 in forum Free Hosting
    Replies: 5
    Last Post: 03-27-2007, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers