Since some time ago I have been programming in php with oracle, and I’ve always liked the function oci_error() because the function can give me the byte position of the error in the query (offset) and then I can make a function to show the error with a flag indicating where is the error in the query.
Well I’m making a similar function but with mysql:
I have the mysql_error() which gives me the “message”.
I have the mysql_errno() which gives me the “code”.
The “sqltext” I can get it with the function itself.
But, How can I get the offset value of the error in the query?
MySQL errors are usually of the type
Following the “near” keyword is the part of the query where the error occurred. You could search for this string using
strpos()in your query and use that as the offset.