Page 1 of 1
problems on transferring my database
Posted: Tue Feb 10, 2004 9:57 am
by nutstretch
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.
Posted: Tue Feb 10, 2004 10:05 am
by twigletmac
Change:
Code: Select all
mysql_fetch_row($resultID, MYSQL_ASSOC)
to
Mac
Posted: Tue Feb 10, 2004 11:33 am
by nutstretch
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?
Posted: Wed Feb 11, 2004 3:49 am
by twigletmac
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:
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>';
?>
Mac
Posted: Wed Feb 11, 2004 10:48 am
by nutstretch
$ county is being passed from the form before. I have tried putting in
print $county;
and it shoes me the value so I am sure that part is working
many thanks for the notes though very useful
Posted: Wed Feb 11, 2004 3:19 pm
by DuFF
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))
{
?>
Posted: Wed Feb 11, 2004 5:00 pm
by nutstretch
Many Thanks yes i think i did
