Jump to content

Extra Spaces at end of Data retrivial using varchar?


stig1

Recommended Posts

I have set up a table that using a varchar field.

 

In phpmyadmin, i add data, however, when i retrieve the data, it puts extra spaces at the end for some reason? It never use to.

 

I am using mysql 5.

 

So for example i would have a varchar(10) field and i would have the following inserted via phpmyadmin SHOPBAGS but when i extract it via php I get SHOPBAGS  2 Spaces at the end.. so my url looks like the following:

 

browse.php?st=SHOPBAGS  "

 

It happens on all the data in my database, and i do have varchar(10) field as a primary key, would that matter?

No I didn't type a space, as when i go to look at the data in phpMyAdmin, it looks exactly how i typed it, no spaces.

 

Another one of my varchar field holding item information, which is a primary key also has extra spaces to make 15 characters all the time, even if i only type in 5.

 

i didnt use to have this issue.. :(

<?php
$x = "select subtype from subtypsec where prodtype = '$ptID' and division = '$divnID' order by sequence asc, subtype asc";
$xresult = $mysql->query($x);
while ($subtypelist = mysql_fetch_array($xresult)){
	$stID = $subtypelist['subtype'];
	$st = "select descript from prdchgsub where subtype = '$stID'";
	$st_result = $mysql->query($st);
	$st_row = mysql_fetch_row($st_result);
	$subtype = $st_row[0];
?>
			<li>
			<a href="browse.php?pt=<?=$ptID;?>&st=<?=$stID;?>" title="<?= $subtype; ?>"><?= $subtype; ?></a>
			</li>
<?php
}
?>

 

I can put in rtrim() and it will fix it up.. however, I didn't have to do that before on the old database, the new database is exact same fields.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.