sf_tristanb
sf_tristanb

Reputation: 8855

MySQL enters another value that the one given by PHP

The big problem : mysql does not stores the information i told him to via PHP

Example (this req is an echo just before the query) :

INSERT INTO serveur (GSP_nom , IPserv, port, tickrate, membre, nomPays, finContrat, type, jeux, slot, ipClient, email) 
VALUES ( 'ckras', '88.191.88.57', '37060', '100' , '', 'Allemagne','20110519', '2', '4','99' ,'82.220.201.183','[email protected]');

But on the MySQL i have :

403     ckras   88.191.88.57    32767   100         Allemagne   20110519    1   2010-04-25 00:51:47     2   4   99      82.220.201.183  [email protected]

port : 37060 (right value) //// 32767 (MySQL's drug?)

Any help would be appreciated, i'm worse than stuck and i'm **** off

PS: *There is no trigger on the mysql as far as i know / there is no controll on the port which means that nowhere i modify the "port" value

and this script works for 80% of the time ( it seems that as soon as the users enters a port >= 30000 it causes that bug), an user first reported to me this error today and the script was running since 3 months*

Thanks

Upvotes: 3

Views: 211

Answers (2)

Daniel Vassallo
Daniel Vassallo

Reputation: 344291

You are probably using the smallint data type for the port attribute. The maximum value of this data type is 32767.

In fact, I have replicated your problem:

CREATE TABLE a(a smallint);
Query OK, 0 rows affected (0.09 sec)

INSERT INTO a VALUES (37060);
Query OK, 1 row affected, 1 warning (0.02 sec)

SELECT * FROM a;
+-------+
| a     |
+-------+
| 32767 |
+-------+
1 row in set (0.00 sec)

You would simply have to use a larger data type, such as mediumint or int.

Further reading:

Upvotes: 3

Ozmah
Ozmah

Reputation: 130

I had a similar problem not too long ago, I accidentally had tinyint in a field that received a big value, you should check the type of field you're using. Also I recommend that if the problem still persist try getting the data in a string form.

There's some more way you can try and track down the problem, try checking the logs in MySQL for any possible errors or rewriting the functions that inserts the data into MySQL, sometimes the smallest mistake (often hard to spot) can ruin an otherwise fantastic software.

Upvotes: 1

Related Questions