The following code JUST WON'T WORK! What i'm trying to do is if the ID #s in the database 'links' does not start with one and consecutively count through the last row # (start 1, 2, 3, 4, end 5), then it will check each row one by one, if the first row isn't 1, then it'll change it to 1 and so on. But this doesn't work! I don't know why either, i've tried every thing I, an amateur at this PHP, can come up with.
require ("includes.php");
$count = 0;
$result = mysql_query("SELECT * FROM links)
or exit ("Invalid query");
if ($row = mysql_fetch_array($result)) {
do {
$count += 1;
$oID = $row[id];
if ($oID != $count) {
$sql = "UPDATE links SET id='$count' WHERE id=$oID";
$result = mysql_query($sql);
print "oID: $oID <br>"; # used for test results
print "COUNT: $count <br>"; # used for test results
}
} while ($row = mysql_fetch_array($result));
}
I usually end up with the error that says that the MySQL fetch statement is wrong or won't work or something like that.
any help? any tips? any corrections? thanks for your help!