Jump to content

MySQL PHP result stripping leading zeros. Don't know why or how to fix


Recommended Posts

Database column SKU is set up as varchar(30)
Sample SKU items in DB:

MG1334
866jj6
34249
0MFG88367
00A
MUJY082JLKKSOY

$sql = "SELECT sku from marketplace";
$resultdID=$db->query($sql)->fetchAll();
   foreach($resultdID as $row) {
   echo $row['sku']."<br>";
   }

Results:

MG1334
866jj6
34249
MFG88367
A

MUJY082JLKKSOY

What's going on and how to prevent it? When I browse my data with PhpMyAdmin, I have other tables in my system with similar data and I never experienced anything like this. Google Search results say to set my column as VARCHAR but it was always that from day one.

Thanks

 

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.