ok im new to mysql and php and just to get familiar with it i created a stats page that displays hockey stats in my db.
<?php
include('config.php');
echo("<table border='1'>
<tr><td>Name</td><td>Goals</td><td>Assists</td></tr>");
$query= mysql_query("SELECT * FROM stats ORDER BY Goals DESC");
while($row= mysql_fetch_array($query))
{
echo ("<tr><td>".$row["Name"]."</td><td>".$row["Goals"]."</td><td>".$row["Assists"]."</td></tr>");
}
echo("</table>");
?>
then i created a page to enter stats...
<?php
include('config.php');
echo("
Enter your stats!
<form action='thanks.php' method='post'>
<table>
<TR><td>NAME</td><td><input type='text' name=name></td></tr>
<TR><td>Goals</td><td><input type='text' name=goals></td></tr>
<tr><TD>Assists</td><TD><input type='text' name=assists></td></tr>
<TR><TD><input type='submit' value='submit'></td></tr>
</table>
</form>")
?>
and after that...to say thanks for entering your stats and to tell if they worked...
<?php
include('config.php');
$query= mysql_query("INSERT INTO stats ('Name','Goals','Assists') VALUES ('$name','$goals','$assists')");
if ($query) {
echo("Stats Added! THanks!<a href='/stats.php'>GO here</a> to see how you compare");
} else {
echo("Sorry your stats could not be added, please try again");
}
?>
and it always comes up "Sorry your stats could not be added, please try again"...anyone kno y?