yanipan Posted May 8, 2011 Share Posted May 8, 2011 Ok, i've encountered the worse bug in my life. I worked over it for about 12 hours until I found the source, and as always, it is somthing quite stupid... after long research I found that the problem is that there are whitespaces in my DB... the thing is, that I can't get rid of them... I tried to use "trim" - like this: $name = trim($name); and like this: $name = trim($name, ' '); I tried: if ($name[0] = ' ') $name[0] = '' but the little white spaces are still there. I thought it might be non-breaking space html char but when I looked at the source it was still a tiny space. any ideas? thanks When I checked it in phpMyAdmin I couldn't see it in the result list, but when I edited a row it was there and I was able to delete it... I'm not sure what else data is required but please ask anything you need because I'm running out of ideas Quote Link to comment https://forums.phpfreaks.com/topic/235822-need-help-with-getting-rid-of-whitespaces/ Share on other sites More sharing options...
Zane Posted May 8, 2011 Share Posted May 8, 2011 it must be inside the code you use to update the table...or add to it. Show us the code for that. Quote Link to comment https://forums.phpfreaks.com/topic/235822-need-help-with-getting-rid-of-whitespaces/#findComment-1212225 Share on other sites More sharing options...
yanipan Posted May 8, 2011 Author Share Posted May 8, 2011 Hi and Thanks for your help, The code is quite simple, but its a part of a bigger migration system from Interspire to Joomla!. I'm more interested in cleaning the database as it is, because the system is working great except for the migrated terms... either way, here is the code to insert it (it uses some joomla methods): foreach ($tags as $tag) { $database->setQuery("SELECT * from '#__tag_term' WHERE name = '$tag'"); $database->query(); if ($database->getNumRows()>0) { $row = $database->loadAssoc(); $tag_id = $row['tag_id']; } else { $tag = trim($tag); $database->setQuery("INSERT INTO #__tag_term (name) VALUES ('$tag')"); $database->query(); $tag_id = mysql_insert_id(); } $quer = "INSERT INTO #__tag_term_content (tid,cid) VALUES('$tag_id','$art_id')"; $database->setQuery("INSERT INTO #__tag_term_content (tid,cid) VALUES('$tag_id','$art_id')"); $database->query(); } I've attached an image from my PhpMyAdmin, maybe it could help... Y [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/235822-need-help-with-getting-rid-of-whitespaces/#findComment-1212229 Share on other sites More sharing options...
yanipan Posted May 8, 2011 Author Share Posted May 8, 2011 OK, Finally got it... Again, quite silly - Trim function work great, unlike me I didn't update the ID of each row correctly. so each time I only fixed the first row. The names outputted were OK so I assumed the loop worked... Thanks alot for the time and help! Quote Link to comment https://forums.phpfreaks.com/topic/235822-need-help-with-getting-rid-of-whitespaces/#findComment-1212230 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.