Is this a mySQL bug or am I doing something wrong?

liunx

Guest
:confused:
I am working on a site that uses php and mySQL that allows clients to upload photos and information about their home onto the site. The database works okay as long as no rows are deleted in front of the selected rows. If I delete a row then only the row(s) that is displayed after that will be echoed to the website. Is this a bug with mySQL or is there a way to prevent this? Here is an abbreviated version of my code...

<?php
$DBhost = "localhost";
$DBuser = "*****";
$DBpass = "*****";
$DBname = "homesubmit";
$table = "sellersinfo";
$caswell = "Caswell";
mysql_connect($DBhost, $DBuser, $DBpass) or die ("Unable to connect to database.");
mysql_select_db("$DBname") or die ("Unable to select database.");

$ysql = "SELECT * FROM $table WHERE county = '$caswell'";

$yquery = mysql_query($ysql) or die ("Unable to query database.");

$myresult = mysql_fetch_array($yquery);

while($myresult = mysql_fetch_array($yquery)) {
$myforsaleby = stripslashes ($myresult['forsaleby']);
$mycounty = stripslashes ($myresult['county']);
$mycity = stripslashes ($myresult['city']);
$mylotsize = stripslashes ($myresult['lotsize']);
$mysquarefeet = stripslashes ($myresult['squarefeet']);
$mybedrooms = stripslashes ($myresult['bedrooms']);
$mybaths = stripslashes ($myresult['baths']);
$myutilities = stripslashes ($myresult['utilities']);
$mycitytaxes = stripslashes ($myresult['citytaxes']);
$myprice = stripslashes ($myresult['price']);
$mycomments = stripslashes ($myresult['comments']);

echo "<td class=\"listingscontent\" colspan=\"2\" rowspan=\"1\"><a href=http://www.htmlforums.com/archive/index.php/\"temp.html\"><img class=\"nobord\" src=\"myhome.jpg\" width=\"150\" height=\"100\" alt=\"home\">$mycounty, $mylotsize</a></td></tr>";
}
mysql_close();
?>

I know the code isn't complete but I'm in the testing phase. Thanks for having a look.not sure I follow. it doesn't matter what and where the rows are that are deleted, it will still work. can you explain a little better please?

and aslo why do you have 2 mysql_fecth_array's

$myresult = mysql_fetch_array($yquery);

while($myresult = mysql_fetch_array($yquery)) {Hey Scoutt. Actually I found out it wasn't deleting a row that caused an inconsistant number of rows to be echoed. The 2 mysql_fetch_arrays were what was causing the problem. Being a newbie to this I thought the first mysql_fetch_array just defined the variable to be included in the "while" statement. It was actually causing the first row to not be displayed. The first mysql_fetch_array fetched one row but wasn't included in the "while" statement. I just deleted the first mysql_fetch_array and problem was solved! Actually someone in another forum told me this or I'd still be working on it. Thanks for having a look. :D
 
Back
Top