Re: simple issue
| From: | Chris | Date: | Wed, 22 Nov 2006 06:10:57 +0000 |
| Subject: | Re: simple issue | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-42712@lists.php.net to get a copy of this message | ||
Chris Carter wrote:
my code: <html> <body> <? $username="chris"; $password="carter"; $database="chris_phpb1"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM phpbb_banlist"; $result=mysql_query($query); if (!$result) {exit("Error in SQL");} echo "<table><tr>"; echo "<th>Companyname</th>"; echo "<th>Contactname</th></tr>"; while (odbc_fetch_row($result)) { $compname=odbc_result($result,"CompanyName"); $conname=odbc_result($result,"ContactName"); echo "<tr><td>$compname</td>"; echo "<td>$conname</td></tr>"; }Connecting using mysql_connect and then using odbc_fetch_row won't work - they are completely separate interfaces (apart from odbc not being supported on your server). Try while ($row = mysql_fetch_assoc($result)) { $compname = $row['CompanyName']; } See http://www.php.net/mysql_fetch_assoc for more info. -- Postgresql & php tutorials http://www.designmagick.com/