Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8642253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:43:46+00:00 2026-06-12T11:43:46+00:00

For some reason my array values are being cut off in my DB. Here

  • 0

For some reason my array values are being cut off in my DB. Here is my php

<?php
$con = mysql_connect("localhost","Andrew","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("mydb", $con);

$sql="INSERT INTO persons (firstname, lastname, modelid, system, department, comm,    other, shift, comments)
VALUES
('$_POST[firstname]','$_POST[lastname]','$_POST[modelid]','". implode(",",       $_POST['system']) ."','$_POST[department]','". implode(",", $_POST['comm']) ."','".   implode(",", $_POST['other']) ."','$_POST[shift]','$_POST[comments]')";

if (!mysql_query($sql,$con))
  {
 die('Error: ' . mysql_error());
  }
 echo "1 record added";

mysql_close($con);
?> 

What I mean by cutoff is that my checkbox entries are being entered properly, separated by commas and all, but its almost as if there is some sort of character limit that I can enter into a single field. Just messing around I’ve added the mysql_real_escape_string in with no errors thinking that was the problem, but I still have the same issue. Has anyone seen this before or aware of any possible fixes?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T11:43:47+00:00Added an answer on June 12, 2026 at 11:43 am

    Like I said in the comment, better not user mysql_* functions – better use PDO or MySQLi.

    the problem in your code is here:

    $sql="INSERT INTO persons (firstname, lastname, modelid, system, department, comm,    other, shift, comments)
    VALUES
    ('$_POST[firstname]','$_POST[lastname]','$_POST[modelid]','". implode(",",       $_POST['system']) ."','$_POST[department]','". implode(",", $_POST['comm']) ."','".   implode(",", $_POST['other']) ."','$_POST[shift]','$_POST[comments]')";
    
    1. You should sanitize and validate the POST parameters before using them
    2. If you would do #1, you could use parameters like $firstname without string concatenation (which has a missing " before and after the first 3 POST parameters.

    The way I would implement this is something like:

       /*** first sanitize your POST params ***/
       $firstname = mysql_real_escape_string($_POST['firstname']));
       $lastname= mysql_real_escape_string($_POST['lastname']));
       //etc ...
    
       /**the query ***/
       $stmt = $dbh->prepare("INSERT INTO persons (firstname, lastname, modelid, system, department, comm,    other, shift, comments)
    VALUES(:firstname, :lastname, :modelid, :system, :department, :comm, :other, :shift, :comments)");
    
    
       /*** bind the paramaters ***/
       $stmt->bindParam(':firstname', $firstname, PDO::PARAM_STR);
       $stmt->bindParam(':lastname', $lastname, PDO::PARAM_STR);
       // etc...
    
       /*** execute the prepared statement ***/
       $stmt->execute();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason my values are not being stored in the array: var req
I'm getting data from an array. For some reason the array has key values
I am populating an array with variables from a table. For some reason, it
I have a bit of PHP code that's baffling me for some reason. I
To clarify: I'm not using the gettext php module /extension, reason being because I
My list component for some reason is not displaying the data being pulled from
For some reason, this line of code is returning undefined for $(this).attr(href) $(a).attr(href, javascript:page('
for some reason when I try to call CocoaAsyncSocket's onSocket:didReadData:withTag method, it's failing and
For some reason I can't detect I can't set a z index for any
For some reason there's a variable called d that is defined immediately after I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.