# MySQL problem display data from database

**URL:** <https://forum.kirupa.com/t/mysql-problem-display-data-from-database/284710>\
**Category:** programming\
**Created:** [March 22, 2009, 8:38pm UTC](https://forum.kirupa.com/t/mysql-problem-display-data-from-database/284710 "2009-03-22T20:38:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![joso](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@joso](https://forum.kirupa.com/u/joso)\
**Post date:** [March 22, 2009, 8:38pm UTC](https://forum.kirupa.com/t/mysql-problem-display-data-from-database/284710/1 "2009-03-22T20:38:44Z")

</div>

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](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 :

```php
$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:

```php

$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">&nbsp;</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 🙂
