Jump to content

Recommended Posts

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 :)

 

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]

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!

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.