I am trying to keep a database up to date by running this script all the time. It works when I use the implode, but when I use the str replace it keeps giving me errors.
It works this way, from a form.
$MAKE = implode("','",$_POST['MAKE']);
$MODEL = implode("','",$_POST['MODEL']);
$YEAR = implode("','",$_POST['YEAR']);
$CITY = implode("','",$_POST['CITY']);
$STATE = implode("','",$_POST['STATE']);
$ZIP = implode("','",$_POST['ZIP']);
$query = "UPDATE $catagory$subcatagory SET ACTIVE='1' WHERE CLOSEDATE > '$date'";
if($select_make =='1'){
$query.=" AND MAKE IN ('".$MAKE."')";
}
if($select_model =='1'){
$query.=" AND MODEL IN ('".$MODEL."')";
}
etc....
And does not work this way, but need it to work this way.
$selectedzipstr = " $selectedzip";
// Turn the - into ','
$selectedzipstr = str_replace("-", "','", $selectedzipstr);
// Remove the extra ', from the start, and ,' from the end
$selectedzipstr = "'".$selectedzipstr."'";
$query = "UPDATE $catagory$subcatagory SET ACTIVE='1' WHERE CLOSEDATE > '$date'";
if($selectmake =='1'){
$query.=" AND MAKE IN (".$selectedmakestr.")";
}
if($selectmodel =='1'){
$query.=" AND MODEL IN ('".$selectedmodelstr."')";
}
etc......
Thanks in advance.