I am using the JQuery .post method to get data using an AJAX call. The PHP file that is rendering the data has the following code that inputs information into a database:
$query = "INSERT INTO questions(question, added_by) VALUES ('$question', '$user_id')";
$result = mysql_result($query);
//If db error
if(!$result )
{
$error = str_replace("'", "*", mysql_error());
$method = __METHOD__.'line: '.__LINE__;
return Error::db_error($method, $error, $this->ip, 'An internal error has occurred. Your question can not be added at this time.');
}
According to this code, a database error is occurring, yet mysql_error() is blank. When I use die($query), and copy and paste the literal query string into my mysql gui window (sqlyog) and run the query, it inserts just fine with no warnings or errors.
I have this general set-up for some other PHP functions and it works just fine.
I am really stumped by this. Any help would be greatly appreciated. Thanks.
Execute the query using
mysql_querybefore Retrieving the contents of cells from aMySQL result setusingmysql_result.