|
-
May 1st, 2004, 02:16 AM
#1
Thread Starter
Frenzied Member
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
}
?>
-
May 1st, 2004, 03:09 AM
#2
Re: this will not add to my database
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());
-
May 1st, 2004, 03:29 AM
#3
Thread Starter
Frenzied Member
this error
Query Failed: You have an error in your SQL syntax near '1,'1','1','1')' at line 1
-
May 1st, 2004, 03:47 AM
#4
Your quotes are out of sync. Each value should be enclosed in single quotes; some of them are not.
Query Failed: You have an error in your SQL syntax near '1,'1','1','1')' at line 1
In your PHP script:
"INSERT INTO DB_Stats Values ('','$name','$team,'$tries,'$goals','$fgoals','$total');"
-
May 1st, 2004, 04:17 AM
#5
Thread Starter
Frenzied Member
sweet that works well now
hey i'm displaying all the records in my database and just looping them over and over so I can edit the whole lot on one page. once I have change the information do we just run a script like this
PHP Code:
if (! mysql_query ("UPDATE DB_Stats Values ('','$name','$team','$tries','$goals','$fgoals','$total')"))
die ('Query Failed: ' . mysql_error());
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|