Jump to content

Recommended Posts

Not sure if I am doing this correcly, but the SQL database is NOT being loaded. For each person listed on the form, I need to create a seperate record with different information.

You can view the form at:
[a href=\"http://www.usadarts.com/adorep/lod.htm\" target=\"_blank\"]http://www.usadarts.com/adorep/lod.htm[/a]


Form Code
[code]
<form action="post.php" method="POST">
    <b><i>
    <center>
      Enter LOD Results
    </center>
    </i></b>
    <table border="5" cellspacing="10" cellpadding="10" align="center">
      <tr>
        <td> <b>Date:</b> </td>
        <td>
          <select name="date">
            <OPTION VALUE="">Select Date
            <OPTION VALUE="20060304">March 4, 2006
            <OPTION VALUE="20060311">March 11, 2006
            <OPTION VALUE="20060318">March 18, 2006
           </select>
        </td>
      </tr>
      <tr>
        <td valign="top"> <b>Number of Entries:</b> </td>
        <td>
          <input type="text" name="entries" size="3">
        </td>
      </tr>
      <tr>
        <td valign="top"> <b>1st Place:</b> </td>
        <td> Player 1
          <input type="text" name="1sta" size="30">
          <br>
          Player 2
          <input type="text" name="1stb" size="30">
        </td>
      </tr>
      <tr>
        <td valign="top"> <b>2nd Place:</b> </td>
        <td> Player 1
          <input type="text" name="2nda" size="30">
          <br>
          Player 2
          <input type="text" name="2ndb" size="30">
        </td>
      </tr>
      <tr>
        <td valign="top"> <b>3/4th Place:</b> </td>
        <td> Player 1
          <input type="text" name="3rda" size="30">
          <br>
          Player 2
          <input type="text" name="3rdb" size="30">
        </td>
      </tr>
      <tr>
        <td valign="top"> <b>3/4th Place:</b> </td>
        <td> Player 1
          <input type="text" name="4tha" size="30">
          <br>
          Player 2
          <input type="text" name="4thb" size="30">
        </td>
      </tr>
      <tr>
        <td>
          <input type="reset" name="Submit" value="Clear Form">
        </td>
        <td>
          <input type="submit" name="Submit" value="Submit Form">
        </td>
      </tr>
    </table>
  </form>[/code]

and here is the PHP code:
[code]
<?php
$event = 'Ringside Pub LOD'
$date = $_POST['date'];

$dbh=mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("username_rankings");

$player = $_POST['1sta'];
$place = '1st';
$points = 5 * $_POST['entries'];
$insert = "INSERT INTO 2006 (date, event, player, place, entries, points)
    VALUES ('$date', '$event', '$player', '$place', '$entries', '$points')";
$results = mysql_query($insert);

$player = $_POST['1stb'];
$place = '1st';
$points = 5 * $_POST['entries'];
$insert = "INSERT INTO 2006 (date, event, player, place, entries, points)
    VALUES ('$date', '$event', '$player', '$place', '$entries', '$points')";
$results = mysql_query($insert);

$player = $_POST['2nda'];
$place = '2nd';
$points = 3 * $_POST['entries'];
$insert = "INSERT INTO 2006 (date, event, player, place, entries, points)
    VALUES ('$date', '$event', '$player', '$place', '$entries', '$points')";
$results = mysql_query($insert);

$player = $_POST['2ndb'];
$place = '2nd';
$points = 3 * $_POST['entries'];
$insert = "INSERT INTO 2006 (date, event, player, place, entries, points)
    VALUES ('$date', '$event', '$player', '$place', '$entries', '$points')";
$results = mysql_query($insert);

$player = $_POST['3rda'];
$place = 'Top 4';
$points = 1 * $_POST['entries'];
$insert = "INSERT INTO 2006 (date, event, player, place, entries, points)
    VALUES ('$date', '$event', '$player', '$place', '$entries', '$points')";
$results = mysql_query($insert);

$player = $_POST['3rdb'];
$place = 'Top 4';
$points = 1 * $_POST['entries'];
$insert = "INSERT INTO 2006 (date, event, player, place, entries, points)
    VALUES ('$date', '$event', '$player', '$place', '$entries', '$points')";
$results = mysql_query($insert);

$player = $_POST['4tha'];
$place = 'Top 4';
$points = 1 * $_POST['entries'];
$insert = "INSERT INTO 2006 (date, event, player, place, entries, points)
    VALUES ('$date', '$event', '$player', '$place', '$entries', '$points')";
$results = mysql_query($insert);

$player = $_POST['4thb'];
$place = 'Top 4';
$points = 1 * $_POST['entries'];
$insert = "INSERT INTO 2006 (date, event, player, place, entries, points)
    VALUES ('$date', '$event', '$player', '$place', '$entries', '$points')";
$results = mysql_query($insert);
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/6484-loading-sql-problem/
Share on other sites

Receiving the following 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 'Blind Draw, David Hascup, 1st, 12, 60)' at line 2


[code]
<?php
$event = "Ringside Blind Draw";
$date = $_POST['date'];

$dbh=mysql_connect ("localhost", "username", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("username_rankings");

$player = $_POST['1sta'];
$place = '1st';
$points = 5 * $_POST['entries'];
$insert = "INSERT INTO `2006` (`date`, `event`, `player`, `place`, `entries`, `points`)
    VALUES ($date, $event, $player, $place, $entries, $points)";
$results = mysql_query($insert) or die(mysql_error());
[/code]
Link to comment
https://forums.phpfreaks.com/topic/6484-loading-sql-problem/#findComment-23506
Share on other sites

looks like you might have the quotations switched around in your INSERT query

try changing
[code]
$insert = "INSERT INTO `2006` (`date`, `event`, `player`, `place`, `entries`, `points`)
    VALUES ($date, $event, $player, $place, $entries, $points)";
[/code]

to
[code]
$insert = "INSERT INTO `2006` (date, event, player, place, entries, points)
    VALUES ('$date', '$event', '$player', '$place', '$entries', '$points')";
[/code]
Link to comment
https://forums.phpfreaks.com/topic/6484-loading-sql-problem/#findComment-23695
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.