Click to See Complete Forum and Search --> : [RESOLVED] sending 2009 becomes 127 ???


riddellchris
01-14-2009, 08:53 PM
When i send the year 2009 to MySQL it is saving at 127. Is this some issue because of the zeros?

Below is the data that I'm sending in two groups, first the column names and then secondly the values "data_sent" is not part of this.

All other parts appear properly accept the year....

infact even when i choose other years they are all showing up at 127

Thanks for any help!

Array
(
[begDay] => 1
[begMonth] => 1
[begYear] => 2009
[endDay] => 3
[endMonth] => 1
[endYear] => 2009
[open_hours_a] => 12
[open_minutes_a] => 15
[open_ap_a] => PM
[close_hours_a] => 3
[close_minutes_a] => 30
[close_ap_a] => PM
[day_id_a_1] => 1
[date_day_a_1] => 1
[date_month_a_1] => 1
[date_year_a_1] => 2009
[day_id_a_2] => 2
[date_day_a_2] => 2
[date_month_a_2] => 1
[date_year_a_2] => 2009
[day_id_a_3] => 3
[date_day_a_3] => 3
[date_month_a_3] => 1
[date_year_a_3] => 2009
[no_event_days] => 3
[event_multi_days_same_oc_a] => yes
[Submit] => Submit
)

open_hours,open_minutes,open_ap,close_hours,close_minutes,close_ap,event_multi_days_same_oc,day_id,d ate_day,date_month,date_year'12','15','PM','3','30','PM','yes','1','1','1','2009'data sentopen_hours,open_minutes,open_ap,close_hours,close_minutes,close_ap,event_multi_days_same_oc,day_ id,date_day,date_month,date_year'12','15','PM','3','30','PM','yes','2','2','1','2009'data sentopen_hours,open_minutes,open_ap,close_hours,close_minutes,close_ap,event_multi_days_same_oc,day_ id,date_day,date_month,date_year'12','15','PM','3','30','PM','yes','3','3','1','2009'data sent

chazzy
01-14-2009, 09:55 PM
what's the table structured like? are you using an int(3) by any chance to store "2009" ? What happens if you send 2008?

riddellchris
01-14-2009, 10:58 PM
without adjusting my form i can't do 2008, but 2010 gives me the same number 127...?

Below is the table creation file

after that is a section of a php file that i'm using to send the data. the two strings of names and values are displayed via the echo statements just above and then obviously put into the query. Hope that make sense!

Thanks for your help!

<?php
//connect to MySQL
// need to use correct hostname, user and password
$connect = mysql_connect("localhost", "root", "freakonaleash") or
die ("Hey loser, check your server connection.");

//create the main database if it doesn't already exist
$create = mysql_query("CREATE DATABASE IF NOT EXISTS testing")
or die(mysql_error());

//make sure our recently created database is the active one
mysql_select_db("testing");

//create "abe_date_time_details" table
$create_table = "CREATE TABLE abe_date_time_and_oc (
entry_no bigint NOT NULL auto_increment,
letter_multiple char(1) NOT NULL,
event_multi_days_same_oc varchar(3) NOT NULL,
day_id smallint NULL,
date_day tinyint NULL,
date_month tinyint NULL,
date_year tinyint NULL,
open_hours tinyint NULL,
open_minutes tinyint NULL,
open_ap char(2) NULL,
close_hours tinyint NULL,
close_minutes tinyint NULL,
close_ap char(2) NULL,
PRIMARY KEY (entry_no)
)";

$results = mysql_query($create_table)
or die (mysql_error());

echo "abe_date_time_and_oc table succesfully created!";
?>
echo "$_SESSION[columns_to_send]";
echo "$_SESSION[values_to_send]";

// send those fields to the appropriate table and column
$query = "INSERT INTO abe_date_time_and_oc ($_SESSION[columns_to_send]) VALUES ($_SESSION[values_to_send]);";
$result = mysql_query($query)
or die(mysql_error());
echo "data sent";

skywalker2208
01-14-2009, 11:15 PM
TINYINT only goes up to 127. You probably want to use smallint.
http://www.htmlite.com/mysql003.php

TheTeenScripter
01-15-2009, 01:41 AM
the first thing that reminded me of is the start of the loopback ip lmao

riddellchris
01-15-2009, 02:56 AM
oh my! thanks guys! it's the first time i've tried to be more specific with the data types and i managed to stuff it so badly!

Thanks!!!!!!!!!