i am have tried out my database etc on my local machine and have uploaded it to a web server to test
I am getting an error on my fetch row. wrong parameter count for mysql_fetch_row()
my row says
while ($row = mysql_fetch_row($resultID, MYSQL_ASSOC))
my php is 4.0
the server is 4.3.3 is this why and does anyone know how i change it.
problems on transferring my database
Moderator: General Moderators
-
nutstretch
- Forum Contributor
- Posts: 104
- Joined: Sun Jan 11, 2004 11:46 am
- Location: Leicester
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Change:
to
Mac
Code: Select all
mysql_fetch_row($resultID, MYSQL_ASSOC)Code: Select all
mysql_fetch_assoc($resultID)-
nutstretch
- Forum Contributor
- Posts: 104
- Joined: Sun Jan 11, 2004 11:46 am
- Location: Leicester
many thanks for that. My search is returning noting now when I know it should and was on my machine
$resultID = mysql_query("SELECT * FROM tblcountyname where countyID = '$county'", $linkID)or die(mysql_error());
$num = mysql_num_rows($resultID);
print "<table border=0 ><tr><th> CountyNear</th>";
print "<th> RetailerName</th><th>WebAddress</th>" ;
print "<tr>";
//while ($row = mysql_fetch_row($resultID, MYSQL_ASSOC))
while ($row = mysql_fetch_assoc($resultID))
{
$countyname1 = $row['CountyNear'];
$resultID1= mysql_query("SELECT * FROM tblretailer WHERE RetailerCounty LIKE '$countyname1'", $linkID) or die(mysql_error());
while ($row2 = mysql_fetch_assoc($resultID))
{
print "<td>".$row2['RetailerCounty']."</td>";
print "<td>".$row2['RetailerName']."</td>";
print "<td>".$row2['RetailerWeb']."</td>";
print "<tr>";
}
}
print"</table>";
any ideas?
$resultID = mysql_query("SELECT * FROM tblcountyname where countyID = '$county'", $linkID)or die(mysql_error());
$num = mysql_num_rows($resultID);
print "<table border=0 ><tr><th> CountyNear</th>";
print "<th> RetailerName</th><th>WebAddress</th>" ;
print "<tr>";
//while ($row = mysql_fetch_row($resultID, MYSQL_ASSOC))
while ($row = mysql_fetch_assoc($resultID))
{
$countyname1 = $row['CountyNear'];
$resultID1= mysql_query("SELECT * FROM tblretailer WHERE RetailerCounty LIKE '$countyname1'", $linkID) or die(mysql_error());
while ($row2 = mysql_fetch_assoc($resultID))
{
print "<td>".$row2['RetailerCounty']."</td>";
print "<td>".$row2['RetailerName']."</td>";
print "<td>".$row2['RetailerWeb']."</td>";
print "<tr>";
}
}
print"</table>";
any ideas?
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Since the syntax looks correct it is likely a problem with passing variables - where does $county come from for instance? Below is code with debugging built in:
Mac
Code: Select all
<?php
// set error reporting to display and to it's highest level in case
// it's not and you're missing vital notices and/or warnings:
ini_set('display_errors', 1);
error_reporting(E_ALL);
// separate the SQL statement out because it is easier to debug that way
// you only want one of the columns from the table so name it, don't
// waste the database's time retrieving all columns.
$sql = "SELECT CountryNear FROM tblcountyname WHERE countyID = '$county'";
// DEBUG - check the SQL statement is ok:
echo '<p>SQL Statement 1: '.$sql.'</p>';
$resultID = mysql_query($sql, $linkID)or die(mysql_error().'<p>'.$sql.'</p>');
$num = mysql_num_rows($resultID);
// DEBUG - check whether you have any results:
echo '<p>Num Results 1: '.$num.'</p>';
// you should consider breaking out of PHP to do the HTML or use heredoc
// format to make the HTML easier to maintain (and to add formatting to
// the outputted source)
print '<table border="0"><tr><th>CountyNear</th>';
print '<th>RetailerName</th><th>WebAddress</th>';
print '</tr>';
while ($row = mysql_fetch_assoc($resultID))
{
$countyname1 = $row['CountyNear'];
// again, separate out the SQL statement and explicitely name the
// columns you want to retrieve
$sql = "SELECT RetailerCounty, RetailerName, RetailerWeb FROM tblretailer WHERE RetailerCounty = '$countyname1'";
// DEBUG - check the new SQL statement:
echo '<p>SQL Statement 2: '.$sql.'</p>';
$resultID1= mysql_query($sql, $linkID) or die(mysql_error().'<p>'.$sql.'</p>');
// DEBUG - check whether you have any results:
echo '<p>Num Results 2: '.mysql_num_rows($resultID1).'</p>';
while ($row2 = mysql_fetch_assoc($resultID))
{
print '<tr>';
print '<td>'.$row2['RetailerCounty'].'</td>';
print '<td>'.$row2['RetailerName'].'</td>';
print '<td>'.$row2['RetailerWeb'].'</td>';
print '</tr>';
}
}
print '</table>';
?>-
nutstretch
- Forum Contributor
- Posts: 104
- Joined: Sun Jan 11, 2004 11:46 am
- Location: Leicester
I think you just messed up on one of the variable names.
Code: Select all
<?php
$resultID1= mysql_query("SELECT * FROM tblretailer WHERE RetailerCounty LIKE '$countyname1'", $linkID) or die(mysql_error());
// USED TO BE: while ($row2 = mysql_fetch_assoc($resultID)), should of had a "1"
while ($row2 = mysql_fetch_assoc($resultID1))
{
?>-
nutstretch
- Forum Contributor
- Posts: 104
- Joined: Sun Jan 11, 2004 11:46 am
- Location: Leicester