Can somebody please tell me what is wrong with the code below. If the record exists then part one works but if not I get the above syntaxt error message
$db=odbc_connect($dsn,$usr,$pass);
//echo "Current Directory - $cur_dir<br>";
if (!$db) {
Echo "Unable to open db - $dsn<br>";
} else {
$query="SELECT * ";
$query.="FROM pages ";
$query.="WHERE page= '$page' ";
$result=odbc_do($db,$query);
$num=odbc_num_rows($result);
$ID=intval(odbc_result($result,1));
echo "Database returned $num rows. This record is '$ID'<br>";
if ($ID>=1) {
$hits=intval(odbc_result($result,3));
echo "$ID.$page was $hits hits, ";
$num=$hits+1;
echo "now $num hits.<br>";
$query="UPDATE pages ";
$query.="SET hits=$num ";
$query.="WHERE ID=$ID ";
$result=odbc_do($db,$query);
} else {
$num=1;
echo "New row - $page - $num<br>";
$query="INSERT INTO pages ";
$query.="SET page='$page', hits='$num'; ";
$result=odbc_do($db,$query);
}
}
$db=odbc_connect($dsn,$usr,$pass);
//echo "Current Directory - $cur_dir<br>";
if (!$db) {
Echo "Unable to open db - $dsn<br>";
} else {
$query="SELECT * ";
$query.="FROM pages ";
$query.="WHERE page= '$page' ";
$result=odbc_do($db,$query);
$num=odbc_num_rows($result);
$ID=intval(odbc_result($result,1));
echo "Database returned $num rows. This record is '$ID'<br>";
if ($ID>=1) {
$hits=intval(odbc_result($result,3));
echo "$ID.$page was $hits hits, ";
$num=$hits+1;
echo "now $num hits.<br>";
$query="UPDATE pages ";
$query.="SET hits=$num ";
$query.="WHERE ID=$ID ";
$result=odbc_do($db,$query);
} else {
$num=1;
echo "New row - $page - $num<br>";
$query="INSERT INTO pages ";
$query.="SET page='$page', hits='$num'; ";
$result=odbc_do($db,$query);
}
}