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

MySQL:ERROR_1067

MySQL:ERROR_10...

最近安裝了Ubuntu Server .系統。 接著安裝了MySQL 5..的版本。 在時間的預設值...

js判斷字母是否為大小寫

js判斷字母是否為大小寫

使用JS來判斷字串裡是否含有大寫字母或小寫字母。 //判斷是否含有大寫字母 function chk...

jQuery resize取得瀏覽器目前視窗寬度

jQuery resize取...

pexelsphotokeyboard5 在使用CSS調整RWD顯示時~ 也可以使用javascri...

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