update custom db table row via a plugin page through http url
-
My plugin creates a new table in the database and from the admin page, you can add a new entry to that table which includes the name of the advertiser entered along with the ID, mouseover and clickthrough fields.
My last step is getting separate mouseover and clickthrough php files to update the data in the row associated with the id.
Example situation:
a user clicks on the advertisement and the link would hit the php file.https://mysite.com/wp-content/plugins/my-plugin/clickcount.php?id=1
I need that php file to be able to update the clickthrough field associated with that ID in the custom db table I set up.
I have all this working completely outside of wordpress, but I’m a little lost trying to add this function into WP.
Here is the code in my clickcount.php file:
<?PHP $my_mysql = @mysql_connect('MY HOST HERE', 'USER', 'PASSWORD', true); if ( !$my_mysql ) { echo mysql_error(); // and bail out… } if ( !@mysql_select_db('PASSWORD', $my_mysql) ) { echo 'Could not select database!'; // and bail out… } $table_name = "ad_counter"; extract($_GET); $sql = "SELECT * FROM $table_name WHERE id = $id, $my_mysql"; $result = @mysql_query($sql, $connection) or die(mysql_error()); while ($row = mysql_fetch_array($result)) { $clickthrough = $row['clickthrough']; } //UPDATE VIEW CONNECTION $clickthrough = $clickthrough +1; $query="UPDATE $table_name SET clickthrough = '$clickthrough' WHERE id= $id, $my_mysql"; $result=mysql_query($query); header("location: $adurl"); ?>
I don’t get any errors with this code, but it doesn’t update the db field either.
Any help will be EXTREMELY appreciated. Thanks in advance!
- The topic ‘update custom db table row via a plugin page through http url’ is closed to new replies.