![]() |
Trouble Retrieving Records From Database
Hi
I'm currently working on a website where people can submit links to music they have made. The submission form is now working (thanks to help from Styx) but now when I try to retrieve the contents of the database to display them on a page it doesn't seem to be able to. Here's the code I'm using to display them: [php] $username="*******"; $password="*******"; $database="*******"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die("Unable to connect to database"); $query="SELECT * FROM tunes"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; echo '<table border="1" align="center"> <tr> <td colspan="4"><center>Database contents</center></td> </tr> <tr> <td>Artist</td><td>Title</td><td>Genre</td><td>URL</td>'; while($i<$num) { $title=mysql_result($result,$i,"title"); $artist=mysql_result($result,$i,"artist"); $genre=mysql_result($result,$i,"genreID"); $url=mysql_result($result,$i,"url"); echo "<tr> <td>$artist</td> <td>$title</td> <td>$genre</td> <td>$url</td> </tr>"; $i++; } echo "</table>"; [/php] All the attribute names are correct and I'm doing things exactly the same as a tutorial said but this is how it's coming out: http://www.electricjustice.com/viewtracks.php As you can see, only the 'title' and 'url' attributes are being shown Any advice? Thanks Banjo |
Change query to be this:
$query="SELECT title,artist,genreID,url FROM tunes"; Then try this while loop... :
while ($myrow = mysql_fetch_row($result))I haven't tested this, but it should work. |
Quote:
|
hah, always the small things eh?
|
Yeah - too much of the time
|
| All times are GMT -5. The time now is 11:30 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC