Jump to content

redirect if id is empty


frank_solo

Recommended Posts

This worked

<?php
session_start();
include 'config.php';
$url_id = mysql_real_escape_string($_GET['id']);
$sql = "SELECT id FROM places WHERE id='$url_id' AND unit='Residential' AND county='New Jersey'";
$result = mysql_query($sql);
if(mysql_num_rows($result) >0){
   //found
   $query="UPDATE `places` SET `views` = `views` + 1 WHERE `id` = $url_id";

}else{
   //not found
   header("location: http://www.mydomain.co");
}
?>

But now this won't work
$query="UPDATE `units` SET `views` = `views` + 1 WHERE `id` = $url_id";

Can someone show me how to make that statement work or should I start a different thread?

Thanks

Got it:
 

<?php
include "config.php";
$id = mysql_real_escape_string((int)$_GET['id']);
$sql = "SELECT id FROM places WHERE id='$id' AND unit='Residential' AND county='New Jersey'";
$result = mysql_query($sql);
if(mysql_num_rows($result) >0){
   //found
   
}else{
   //not found
   header("location: http://www.mydomian.co");
}
$query = "UPDATE `units` SET `views` = `views` + 1 WHERE `id` = $id";
$res = mysql_query($query, $bd);
$query = "SELECT * FROM `places` WHERE `id` = $id";
$res = mysql_query($query, $bd);
$result = mysql_fetch_assoc($res);
$lat = $result['lat'];
$contact = $result['contact'];
$phone = $result['phone']; 
$long = $result['lng'];
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.