Loading...

PDO PHP - PDOException - Numeric value out of range: 1264 Out of range value for column user_ip at row 1

Temperature: 0 °C

Mark ChangMark Chang
author_tools

最近遇到一個問題,一個Mysql的錯誤訊息。

我想要紀錄一個IP資訊,我會先用以下方式擷取用戶端使用者IP

sprintf("%u", ip2long($_SERVER['REMOTE_ADDR']))

然後再把資訊存入到Mysql...

在測試端時我測試一切正常,但在客戶端卻出現500的錯誤訊息且錯誤代碼1264。

原因是客戶端使用的IP是IPV6,長度較長,這點我倒是沒考慮到。

所以當我把資料庫欄位從屬性int改為bigint,又或者把int的長度變更就可以解決。
BIGINT
從-2^63 (-9223372036854775808) 到2^63-1 (9223372036854775807) 的整型數據(所有數字)。存儲大小為8 個字節。
INT
從-2^31 (-2,147,483,648)到2^31 – 1 (2,147,483,647)的整型數據(所有數字)。存儲大小為4個字節。

以上紀錄~

#php  #PDO  #Mysql  #錯誤訊息  #IPV6  #bigint  #int  #500  
https://innstory.com/story-PDO_PHP__PDOException__Numeric_value_out_of_range_1264_Out_of_range_value_for_column_userip_at_row_1-2566
Mysql

Prev
 htaccess與RewriteEngine一起使用時500內部服務器錯誤

Next
在PHP中如何將NAN轉換為0 

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

使用jquery判斷上傳檔案大小

使用jquery判斷上傳檔案...

首先得引用jquery var fileSize = document.getElementById...

使用手機將網址分享到 Line時,如何強制使用預設(外部)瀏覽器開啟?

使用手機將網址分享到 Lin...

如標題,當厭惡了每次在line上面分享demo網址給客戶時點選網址就會使用line的瀏覽器開啟。 還...

使用PHP取得指定月份最後一天的日期

使用PHP取得指定月份最後一...

使用PHP要如何抓某個月份的最後一天 例如抓本月份的話可以使用下列範例: date(&#;Ymt&#...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format