tunnelboy Posted May 5, 2023 Share Posted May 5, 2023 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 34249MFG88367 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 Quote Link to comment https://forums.phpfreaks.com/topic/316259-mysql-php-result-stripping-leading-zeros-dont-know-why-or-how-to-fix/ Share on other sites More sharing options...
requinix Posted May 5, 2023 Share Posted May 5, 2023 What does var_dump($row['sku']) output? Quote Link to comment https://forums.phpfreaks.com/topic/316259-mysql-php-result-stripping-leading-zeros-dont-know-why-or-how-to-fix/#findComment-1608102 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.