Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- try{
- ///////////////////////////////////////////////////////////
- $zip = mysql_real_escape_string($_GET['zipcode']); //////
- ///////////////////////////////////////////////////////////
- $host ='localhost'; ///////////////////////////////////////////////
- $dbname ='fannedup_mkt';///////////////////////////////////////////
- $user ='root'; ////////////////////////////////////////////////
- $pass =''; ////////////////////////////////////////////////
- $dbh = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);///
- ///////////////////////////////////////////////////////////////////
- $dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
- $sth = $dbh->prepare(
- 'SELECT fanDetLocID, fanDetLocCity, fanDetLocState FROM fanDetailLocation WHERE fanDetLocZip = ?');
- $sth->bindParam(1, $zip);
- $sth->execute();
- $jsonArray = array();
- while ($result = $sth->fetch(PDO::FETCH_ASSOC)) {
- $jsonArray[] = array(
- 'label' => $result['fanDetLocID'],
- 'value' => $result['fanDetLocCity']);
- }
- print $jsonArray; // print results of array
- print json_encode($jsonArray); // json encode that array
- catch(PDOException $e){
- file_put_contents('../../../PDODBConnectionErrors.txt', 'ERROR: [getFanLoc.php] about '.$e->getMessage().'<br>', FILE_APPEND);
- }
- ?>
Add Comment
Please, Sign In to add comment