简体   繁体   中英

PHP: is it possible to convert a mysqli error number into a mysqli error?

I have two different php pages. The first page is using mysql(i) and the second not. Since I use php header() function to go to the second page, I can only pass $_GET[] variables to the second page. These variables can have a limited value. I wanted to send the mysqli error, if there is one, to the second page, but using mysqli_error I have a very large string. I was wondering if it is possible to use mysqli_errno , which gives me a number which isn't that large, and convert it on the second page with a php function to a mysqli_error string. It would save me a lot of work instead of making lines of code to cover all possible errors. I have searched in several search engines for converting mysqli_errno into mysqli_error , but I could only find converting mysql into mysqli.

Thanks in advance.

It's not the most elegant solution, but you could

Page 1

  1. Pass the error number to page 2 as a URL parameter.

Page 2

  1. Pick up the error number with $_GET
  2. If the error number isn't 0, re-run the query and use mysqli_error to get the string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM