Jump to content

[SOLVED] Fixing improperly inserted data


mikeg542

Recommended Posts

So I inserted some 2000 rows of data (as in, I'd rather not have to do this manually), and all the values in the 'name' field were inserted with a link break somehow.

 

As in, if I go into php my admin and click edit the row, it allows me to move the cursor down to the next row (which isn't supposed to happen.)

 

This currently makes it so that if I search ("SELECT * from table where name='user1') for example, it doesn't find it because user1 was somehow submitted as 'user1 ' (but a line break I THINK instead of a space)

 

Is there an easy way to just change my select statements to look for it WITH a line break? Or, is there a quick piece of code that would get rid of the extra space in all my tables?

 

Thanks!

Link to comment
Share on other sites

well with regular expressions you can say get rid of the /n/r and naything else you want to get rid of and then you can re update the record with the new value, use php to do your reg exp

 

 

result = sql = get all from table

 

while (record = mysqlgetarray(result)){

      new_username = ereg_replace("/r/n", "", result['name']);

    // add other things to ur reg exp aswell [1-9][a-z] i think \z* means 1 from last and you can replace it with ""

    update table set name = 'new_username' where id = result['id']

}

Link to comment
Share on other sites

Trim didn't work, nor did the ereg replace, regretably.

 

I have a temporary fix in using LIKE 'name%' Which would work in the program as none of the names would double trigger that search function. But I would prefer to find a fix incase it does come up :(

 

 

listen you need to do an reg exp that says anything that isnt a number and and isnt a characher alpha i dont know how to negate but it is as follows [a-z 1-9]

Link to comment
Share on other sites

UPDATE tbl SET name = REPLACE(REPLACE(name, '\r', ''), '\n', '');

 

what if its a vbCrlf not a /r or /n or what if its a /r/n

vbCrlf is a constant used in languages based around MS basic.

 

im not with you my knowledge is not vast on that side, but i remember trying to remove new lines in ASP a few years back and it took me ages until i removed the vbCrlf, so i was thinking it may have gone in as that, or would that be what ASP calls it in the code ?

Link to comment
Share on other sites

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.