Hi there,
I’m pretty new to MySQL and I’ve just been trying to create a simple form to submit match fixtures to a database to display on a website for my local angling club. I seem to be having a problem with getting to the data to input into the fields of the table within the database.
Link here,
http://www.predator-uk.net/book/matches.php
The code is as follows for the script to add entries which I’m guessing could be where the error lies :
$host="localhost";
$username="predator_jeff";
$password="giggsy";
$db_name="predator_senior_matches";
$tbl_name="matches";
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="INSERT INTO $tbl_name(month, day, date, comp, venue, draw, fish)VALUES('$month', '$day', '$date', '$comp', '$venue', '$draw', '$fish')";
$result=mysql_query($sql);
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='matches.php'>Go Back</a>";
}
else {
echo "ERROR";
}
mysql_close();
the following script is to display the entries:
$host="localhost";
$username="predator_jeff";
$password="giggsy";
$db_name="predator_senior_matches";
$tbl_name="matches";
mysql_connect("$host", "$username", "$password")or die("cannot connect server ");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
$result=mysql_query($sql);
while($rows=mysql_fetch_array($result)){
?>
<br>
<? echo $rows['month']; ?>
<table width="520" border="0" cellspacing="0" cellpadding="0"><tr>
<td width="28" align="left" valign="top"><? echo $rows['day']; ?></td>
<td width="18" align="left" valign="top"><? echo $rows['date']; ?></td>
<td width="36" align="left" valign="top"> </td>
<td width="117" align="left" valign="top"><? echo $rows['comp']; ?></td>
<td width="148" align="left" valign="top"><? echo $rows['venue']; ?></td>
<td width="87" align="left" valign="top"><? echo $rows['draw']; ?></td>
<td width="86" align="left" valign="top"><? echo $rows['fish']; ?></td>
</tr></table><br><br></p>
<p><BR>
<?
}
mysql_close();
If anyone could offer any advice as to what might be up with it that would be great,
Regards,
Jeff