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

Android Fragment及Activity 中使用sharedpreferences

Android Fragme...

在Android下想要儲存執行資料的方式有好幾種,例如存在手機空間或者是資料庫空間。 這裡紀錄一下使...

當域名 DNS 尚未生效時,如何預先設定及測試網站

當域名 DNS 尚未生效時,...

建置一個新的網站或是將網站搬家時 常常會遇到一個問題,就是要將網址指向到新的網站空間,設定完畢但需要...

解決svchost.exe消耗記憶體問題

解決svchost.exe消...

pexelsphotowin55 根據微軟中文知識庫編號5的文件說明:「SVCHOST.EXE是從動...

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