Checking database, before updating
Posted: Sun Jul 01, 2007 1:40 pm
Anyone have any ideas why this is not works:
Im trying to check the database to see if the url exist (in the db) before writting over it
It seems to write over the url regardless of it already being present in the db
Im trying to check the database to see if the url exist (in the db) before writting over it
Code: Select all
mysql_connect("correctip", "correctUsename", "Correctpass") or die(mysql_error());
mysql_select_db("correcttable") or die(mysql_error());
$URLdata = mysql_query("SELECT LT_URL FROM lt_Users")or die(mysql_error()); // the querry
$DUP = FALSE;
// need to check if $_POST['LT_URLBox'] already exist, if does, dont update ($DUP = True)
CheckURLExists();
if ($DUP == FALSE){
$result48= mysql_query("UPDATE lt_Users SET LT_URL='$lturlBox' WHERE lt_Name ='$nom' AND lt_Pss='$ps'");
}
FUNCTION CheckURLExists() {
while( $URLinfo = mysql_fetch_array( $URLdata ) ){
if (strtolower($URLinfo['LT_URL']) == strtolower($lturlBox)){$DUP = TRUE;}
}
Return $DUP;
}