Using $wpdb
-
I’m using a $wpdb and it is not recognize, am I missing something out?
my page calls an ajax to a certain php file which is I name get_place.php
this is my ajax, its working
$.ajax({
cache: false,
url: baseurl + ‘/php/get_place.php’,
type: ‘post’,
data: ‘latlang=’ + place.geometry.location + ‘&q=’ + 1
});and this is the get_place.php file
if (isset($_POST['latlang'])){ $latlang = $_POST['latlang']; } if (isset($_POST['q'])){ $q = $_POST['q']; } if($q==1){ $wpdb -> query("INSERT IGNORE INTO <code>tbl_branch</code> SET <code>br_latlang</code> = '".$latlang."';"); } else{ $result = $wpdb -> get_results( "SELECT REPLACE(<code>br_title</code>, ' ', ' '), <code>br_content</code> FROM <code>tbl_branch</code> WHERE <code>br_latlang</code> = '".$latlang."';" ); $row = mysql_fetch_array($result); echo "<div id=\"infobox_content\"> <div id=\"siteNotice\"></div> <h3 id=\"firstHeading\" class=\"firstHeading\">".$row[0]."</h3> <div id=\"bodyContent\"> ".$row[1]." </div> </div>"; }
it gives me an error that $wpdb is not recognized
Notice: Undefined variable: wpdb in C:\xampp\htdocs\public\lianas\wp-content\themes\lianas\php\get_place.php on line 15
Fatal error: Call to a member function get_results() on a non-object in C:\xampp\htdocs\public\lianas\wp-content\themes\lianas\php\get_place.php on line 15
any ideas?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Using $wpdb’ is closed to new replies.