I'm not quite sure whether I should post this here or in a dedicated PHP coding forum, nevertheless forgive me if you feel it is pointless.
I am trying to write my own plugins in wordpress, and I started off by adding some functionality to a plugin already out there (the WPAds). I'm trying to write a couple of functions that track banner clicks.
The easiest way I found was to create a wpads-bannerclick.php file which has an id passed into it. This file then looks at the database to update the amount of clicks the banner has recieved as well as forward the user on to the destination URL.
The problem I am having is referencing the database. I recieve a " " error whenever I try and access the database.
Below is my current code for wpads-bannerclick:
<?php include_once( 'wpads-class.php' ); global $wpdb; $id = $_GET["id"]; $sql = "SELECT * FROM ". $wpdb->prefix . "ads_banners WHERE banner_id = '" . $id; $banners = $wpdb->get_results( $sql ); ?>
It just doesn't seem to like any sort of referencing with the database. Is there something I am doing blidingly obvious with my code that's wrong? Or is there some wordpress function or set of files I'm not referencing.
Any further code you need to look at can be given. A lot of it is written by somebody else, as I said it's really for my own amusement/learning, but I would like to know what I'm doing wrong :)