Hi all, this is the first piece of coding I have attempted before in PHP or html so I have been sniping pieces out of tutorials so far!
I am creating a package to manage the Hockey leagues I run. The first page I have create allows you to create a new team and post it to the mysql database. Now I have all of the form working so far with the form pulling information into drop down boxs and allowing you to input data into databoxes before posting it all to the db.
I have now changed the first box so that you no longer tell the page what id number the team being entered is this will instead be the number of teams currently in the table incrimented once. Now my code reads the rows currently in the table and correctly lists this but when I try and write the number to the table it does nothing yet all the other columns write correctly!
Below is the affected parts of the code:
[php]
<?php mysql_connect("localhost", "********", "*******") or die("Connection Failed"); mysql_select_db("web239-league")or die("db Connection Failed"); $result = mysql_query("select count(1) FROM BL_Teams"); $row = mysql_fetch_array($result); $total1 = $row[0]; echo "Current No. of registered Teams: " . $total1; mysql_close($con); ?>Team Full Name:
Team Short Name:
Link to Logo:
Select Rink or Press Create new Venue link:
<?php $query = "SELECT * FROM BL_Venue"; $result = mysql_query($query); ?> <?php
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
?>
Create New Venue!
Website address:
[/php]
and the file which writes the info to the table:
[php]<?php
$con = mysql_connect(“localhost”, “*******”, “********”);
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}
mysql_select_db(“web239-league”, $con);
$sql=“INSERT INTO BL_Teams (ID, Long_Name, Short_Name, Logo, Rink, Website, Twitter, Facebook, Home_shirt, Away_Shirt, ALT_Shirt, Blurb)
VALUES
(’$_POST[total1]’,’$_POST[longname]’,’$_POST[shortname]’,’$_POST[logo]’,’$_POST[venue]’,’$_POST[website]’,’$_POST[twitter]’,’$_POST[facebook]’,’$_POST[home_shirt]’,’$_POST[away_shirt]’,’$_POST[alt_shirt]’,’$_POST[blurb]’)”;
if (!mysql_query($sql,$con))
{
die('Error: ’ . mysql_error());
}
echo “1 record added”;
mysql_close($con);
?>[/php]
Anyone who could shine a light on this would be greatly appreciated!