is it possible for me to check duplicate record using mysql_fetch_object instead of mysql_fetch_array?
$dbquery = "SELECT * FROM Staffs_Category";
$result = mysql_query($dbquery, $dblink);
while($row = mysql_fetch_object($result)){
$limit = count($row);
}
for($i = 0; $i<limit; $i++) {
if($row == $staffcat || $row == $other) {
echo 'category entered is already in record. please re enter';
}
}
any mistake here?
check for duplicate record
Moderator: General Moderators
-
crimsonluv
- Forum Newbie
- Posts: 9
- Joined: Tue Mar 23, 2004 9:10 pm
- Contact:
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
<-- what i always do
dunno whether this is good or bad but its the way i always do it and it works
mal
Code: Select all
require ("dbhandler.php");
$dbquery = "SELECT something FROM somewhere WHERE username = $username";
$result = mysql_query($dbquery) or die (mysql_error());
$resultarray = mysql_fetch_array($result, MYSQL_ASSOC);
$affected = mysql_num_rows($result);
// query complete
// now lets check for a previous match
if ($affected >= 1)
{
// there is already a match in the database
// do something
exit();
}
else
{
// continue, the username wasnt already in the database
}mal
-
crimsonluv
- Forum Newbie
- Posts: 9
- Joined: Tue Mar 23, 2004 9:10 pm
- Contact: