this will not add to my database
PHP Code:
<title>Stats Admin</title>
<?php
mysql_connect (localhost, user, pass);
mysql_select_db (table);
?>
<?php
if ($action == "save")
{
$result = mysql_query ("INSERT INTO DB_Stats Values ('','$name','$team,'$tries,'$goals','$fgoals','$total')");
?>
<p>
<br>
<font face="Verdana">
<strong><font size="2">THANK YOU<br>
</font>
</strong><font size="2">The new stats has been successfully setup.<br>
</font></font>
<p><font face="Verdana"
size="2"><a href="adminaddnew.php?password=brandce">Return to the main menu</a>
<?php
} else {
?>
<p>
<FONT face=Verdana color=#004080 size=2><STRONG>player
admin</STRONG></FONT> -
</font>
<font face="Verdana"
size="1"> <a href="index.php?password=password">Back to admin main menu</a> | <a href="editstats.php">Edit Stats</a> </font><p>
<font face="Verdana" size="1">Enter your stat details below, if you have any
questions please contact <a href="mailto:[email protected]">me</a></font><hr>
<form method="POST" action="adminaddnew.php?action=save">
<table border="0" width="100%">
<tr>
<td width="50%"><font size="1" face="Verdana">Name:<br>
<input type="text" name="name" size="20"></font></td>
<td width="50%"><font size="1" face="Verdana">
Team:<select size="1" name="team">
<option value="1">team1</option>
<option value="2">team2</option>
</select></font></td>
<td width="100%"><font size="1" face="Verdana">Tries:<br>
<input type="text" name="tries" size="5">
</font></td>
<td width="100%"><font size="1" face="Verdana">F Goals:<br>
<input type="text" name="goals" size="5"></font></td>
<td width="100%"><font size="1" face="Verdana">Goals:<br> <input type="text" name="fgoals" size="5"></font></td>
<td width="100%"><font size="1" face="Verdana">Total:<br> <input type="text" name="total" size="5"></font></td>
</tr>
</table>
<p>
<input type="submit" value="Submit New Stat Data" name="B1"></p>
</form>
<?php
}
?>
Re: this will not add to my database
Quote:
Originally posted by kiwis
PHP Code:
$result = mysql_query ("INSERT INTO DB_Stats Values ('','$name','$team,'$tries,'$goals','$fgoals','$total')");
Your SQL query is full of errors. It is always good practice to check your query has succeed and not just assume that it will as it is not only SQL errors which can cause it to fail. Use this code and it will tell you were your errors are:
PHP Code:
if (! mysql_query ("INSERT INTO DB_Stats Values ('','$name','$team,'$tries,'$goals','$fgoals','$total')"))
die ('Query Failed: ' . mysql_error());