custy913 Posted February 6, 2008 Share Posted February 6, 2008 I've been trying to set up "Find Nearest Shops" script for a several days now. But for some reason, I can't add new stores. Can anyone help me? Thanks require_once('DB.php'); $db = DB::connect("mysql://xxxxx:xxxxx@localhost/xxxxx"); if(!empty($_POST['store_name'])) { $store_name = addslashes($_POST['store_name']); $addr1 = addslashes($_POST['addr1']); $addr2 = addslashes($_POST['addr2']); $manager = addslashes($_POST['manager']); $phone = addslashes($_POST['phone']); $city = addslashes($_POST['city']); $state = addslashes($_POST['state']); $zip = addslashes($_POST['zip']); $notes = addslashes($_POST['notes']); $localq = $db->query("select ziplat, ziplong from zipcodes where zipcode = $zip"); $localr = $localq->fetchRow(DB_FETCHMODE_ASSOC); $ziplat = $localr['ziplat']; $ziplong = $localr['ziplong']; // query the DB $sql = "insert into stores (store_name, addr1, addr2, city, state, zip, phone, manager, notes, ziplat, ziplong) values('$store_name', '$addr1', '$addr2', '$city', '$state', '$zip', '$phone', '$manager', '$notes', $ziplat, $ziplong);"; $q = $db->query($sql); $db->commit(); ?> <font color=red size=3><b><?= $store_name ?> Added.</b></font> <?php $disabled = 'disabled=1'; #exit; } ?> <form action="addstores.php" method="POST"> <table cellspacing=2 cellpadding=2><tr><td> <table cellpadding=0 cellspacing=0 border=0> <?php $q = $db->query("desc stores;"); while($q->fetchInto($row)) { if($tdbg == "C0C0C0") { $tdbg = "E0E0E0"; } else { $tdbg = "C0C0C0"; } if($row[0] == "store_id") { // } else if($row[0] == "ziplat") { next; } else if($row[0] == "ziplong") { next; } else if($row[0] == "notes") { ?> <tr><td><?= $row[0] ?></td></tr> <tr><td colspan=2><textarea name="<?= $row[0] ?>" cols=10 rows=2><?= $$row[0] ?></textarea></td></tr> <?php } else { ?> <tr><?= $row[0] ?></td><td bgcolor=#<?= $tdbg ?>><input type="textbox" size=30 name="<?= $row[0] ?>" value="<?= ${$row[0]} ?>" <?= $disabled ?>></td></tr> <?php } } ?> Link to comment https://forums.phpfreaks.com/topic/89726-find-shops-script-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.