0

I have 18 columns in the database and when I insert 15 it works fine but when I try to add 3 more it doesn't insert anymore. It stops working. When separate the code to make it insert those 3 in a different code into the same table it only inserts those 3 but leaves the others blank. Does phpmyadmin have a limit to the outside input being put into the database? And why is that??? I should be able to input all data from html to php into the database with no problem since I can put that amount of columns in the table.

Here is my php code

if(isset($_POST['submit'])) {
    $host = "";
    $username = "";
    $password = "";
    $dbname ="";
    $conn = mysqli_connect($host, $username, $password, $dbname);
    $nck = $_POST['nck'];
    $CTB = $_POST['ctbn'];
    $CBB = $_POST['ctrbn'];    
   if (!$conn) {
      die("Connection failed: " . mysqli_connect_error());
}
$sql = "INSERT INTO personal_information (first, last,nickname,dob,id,gender,mar_sts,address,country,province,zip_code,city_born,country_born,citzen_sts,position,q,phone,email) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
$stmt = mysqli_stmt_init($conn);
mysqli_stmt_prepare($stmt, $sql);
mysqli_stmt_bind_param($stmt, "ssssssssssssssssss", $FN,$LN,$nck,$dte,$ID,$OP,$MS,$AD,$CT,$PF,$ZC,$CTB,$CBB,$CK,$PA,$q,$P,$EL);
mysqli_stmt_execute($stmt);
mysqli_close($conn);
}

When I put this code into the database it goes blank, but when I remove 3 items for example if I removed q phone and email off it would work. only 15 of these work. The rest 3 refuse to work.

user3783243
  • 5,368
  • 5
  • 22
  • 41
  • _Side note:_ PHPMyAdmin is just a web based management tool for managing MySQL databases. Your application is connecting directly to MySQL and has nothing to do with PHPMyAdmin. – M. Eriksson Dec 31 '22 at 15:12
  • Why values fail? What does error reporting show? If you output variables they have values? – user3783243 Dec 31 '22 at 15:12
  • 1
    Add some proper error handling to see what the actual error is when it "stops working": https://stackoverflow.com/questions/22662488/what-to-do-with-mysqli-problems-errors-like-mysqli-fetch-array-argument-1-m – M. Eriksson Dec 31 '22 at 15:13
  • There is no error showing. I know it works because I have other php coding that I am inserting into the database in different tables and they work perfectly fine. But they have less than 15 values entering into one table. For some reason when I put more than 15 it breaks and it stops working. – Loopy Momy Dec 31 '22 at 15:14
  • Do not close this thing I am not getting any errors. And I have tried to put "mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);" at the beggining of my code before the connection and put "error_reporting(E_ALL); ini_set('display_errors', 1);" but I get no errors still. Nothing in the console log. – Loopy Momy Dec 31 '22 at 22:51
  • Many of your variables (for example: `$FN`, `$LN`, etc) should throwing error (undefined variable) because it is just called but did not define anywhere that where is it come from. If error isn't occur it means you did not set to display errors at all level. – vee Jan 01 '23 at 06:58
  • Some time, PHP in fpm, cgi mode need special config in Apache config file. For example: I have this config to increase data length while calling method `POST`. (`FcgidMaxRequestLen 1000000000` - [see doc](https://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html)). Or if your data is not much but you have many input fields (for example: `name[0]`, ...to `name[9999]`) this will be limited by PHP too. You can avoid this by json encode them in JS to send in one input field then decode in PHP. – vee Jan 01 '23 at 07:02
  • @vee I actually on my own I fixed that and it was still doing the same thing. I did everything in my power to have errors show up to its full extent nothing showed up. I did see however later on somewhere else something was missing but it never showed anything for this problem. – Loopy Momy Jan 07 '23 at 22:11
  • @vee no idea how to do the json encode thing – Loopy Momy Jan 07 '23 at 22:12

0 Answers0