Here is the complete revisted script I wrote:
=========
<?php
// Get db credentials
require ("./db_credentials.php");
// get the SQL statement parts from the query string
if ( $HTTP_GET_VARS['value'] ) { $value = $HTTP_GET_VARS['value']; } else { $value = '1'; }
$table = urldecode($HTTP_GET_VARS['table']);
$field = urldecode($HTTP_GET_VARS['field']);
$where = urldecode($HTTP_GET_VARS['where']);
$sql = "UPDATE $table SET $field=$field+$value WHERE $where;";
// connect to the database
$dbcnx = @mysql_connect($db_server, $db_user, $db_password);
if (!$dbcnx) { echo( "<p>Unable to connect to the database server at this time.</p>" ); exit(); }
if (! @mysql_select_db($db_table) ) { echo( "<p>Unable to locate database <b>" . $db_table . "</b> at this time.</p>" ); exit(); }
$result = @mysql_query(urldecode($sql));
if (!$result) { echo("<p>Error performing query: " . mysql_error() . "</p>"); exit(); }
header("Location: [url]http://[/url]" . $HTTP_GET_VARS['redirect']);
?>
===========
Instead of taking the SQL statement, I limit the scripts use to JUST incrementing a field based on the WHERE clause.
The problem now is with the '+' where I construct the complete $sql.
I am getting the following error out of mysql_error() after I perform @():
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '1 WHERE area=\'Downloads\' AND title=\'Serials 2000\' AND url=[/b]
I have tried to escape the '+' character like '+' but that fails too.
Sean Shrum