Jump to content

[SOLVED] Out of range value adjusted for column


twilitegxa

Recommended Posts

You are attempting to put a value into a column that is greater than what the column definition permits. Assuming you have confirmed that the value is correct and expected, that would indicate that your column definition must be adjusted to accommodate the actual data value.

Link to comment
Share on other sites

  • 2 weeks later...

How can I fix this problem? I haven't changed the code and this code used to work just fine. It is for a discussion board and the value I'm having the problem with is, I think, the automatically entered number for the id.

Link to comment
Share on other sites

I don't understand what exactly I have to do to adjust the column definition. I have it set to int, which appears to only allow 11 characters. Is this what I change? What can I change it to?

Since you haven't shown us (a) the table definition or (b) the value being adjusted, we can't say -- though int supports values up to ~2 billion (~4 billion if unsigned).

Link to comment
Share on other sites

  • 3 weeks later...

When I did the MySQL statement to create the table, I used this:

 

create table forum_topics (

topic_id int not null primary key auto_increment,

topic_title varchar (150),

topic_create_time dattime,

topic_owner varchar (150)

);

 

create table forum_posts (

post_id int not null primary key auto_increment,

topic_id int not null,

post_text text,

post_create_time datetime,

post_owner varchar (150)

);

 

And here is my code for adding the topic:

 

<?php
//check for required fields from the form
if ((!$_POST["topic_owner"]) || (!$_POST["topic_title"])
|| (!$_POST["post_text"])) {
header("Location: addtopic.html");
exit;
}

//connect to server and select database
$conn = mysql_connect("mysql5.webdesignsbyliz.com", "twilitegxa", "minimoon")
or die(mysql_error());
mysql_select_db("smrpg",$conn) or die(mysql_error());

//create and issue the first query
$add_topic = "insert into forum_topics (topic_title,topic_create_time,topic_owner) values
('".$_POST['topic_title']."', now(), '".$_POST['topic_owner']."')";
mysql_query($add_topic,$conn) or die(mysql_error());

//get the id of the last query
$topic_id = mysql_insert_id();

//create and issue the second query
$add_post = "insert into forum_posts (topic_id, post_text, post_create_time, post_owner) values
('$topic_id', '".$_POST['post_text']."', now(), '".$_POST['topic_owner']."')";
mysql_query($add_post,$conn) or die(mysql_error());

//create nice message for user
$msg = "<P>The <strong>$topic_title</strong> topic has been created.</P>";
?>
<html>
<head>
<title>New Topic Added</title>
</head>
<body>
<h1>New Topic Added</h1>
<?php print $msg; ?>
</body>
</html>

 

Right now, the topics and posts are not adding to the tables in the database, but the message is displaying saying that they are, but also this error displays:

 

Notice: Undefined variable: topic_title in C:\wamp\www\do_addtopic.php on line 28

 

I am no longer receiving the error about the out of range adjusted value for column. I guess I fixed that somehow?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.