apostrophe not escaped on second entry - mysql

i have a simple form with a textarea and a save button.
what is entered in the field is stored in mysql and then displayed on another page.
each time you enter stuff in the textarea and save, it saves it on top of what is already stored, making an even longer string, if you see what i mean.
im using mysql_real_escape_string
on testing, when i enter an apostrophe for the first time it is displayed as \' which is correct. but when i enter an apostrophe again it breaks down
what is going on?
thanks

ahh. sorry. just worked it out. i wasnt escaping the original data that was being stored and then added on to the new data - if that makes sense

Related

a single " appearing in a persons name is throwing off a load from my ssis package

Everything was working fine but recently names have been showing up in the data as follows:
John Smith"
The problem with this is the source file is a csv and is already comma delimited and I'm also already using " as a text qualifier because I do have a field for company name that does include a comma. For example:
"Acme roadhouse, llc" - and the text qualifier is keeping all of that in one cell even with the comma.
Any help would be very much appreciated and if you need more information, please let me know.
I have tried changing the text qualifier and I have also messed around with the delimiter. The problem is, I have no control over the source file that is being fed to me. I believe this keeps happening from human error, so if I cant get the data entry people to fix this on their end, I don't know what else to try.

Saving values containing comma's in a HTML Multiple select

I have a HTML multiple select being used which caused no issue until a selection with a comma was entered. When saving / loading the values are split by ',' into a list. Therefore causing an issue
I have tried to find a way of possibly changing the character that is being used to split the values when the form is posted but came to a dead end.
Would be very grateful if someone has any insight into this.
Thanks in advance.
---Update with Code---
The control is created dynamically
Dim SelectName1 As New HtmlSelect
SelectName1.ID = "SelectName" & id
SelectName1.Name = "SelectName"
SelectName1.Multiple = True
and filled by looping though the values.
For Each value As String In Request.Form(idToFind).Split(",")
If Not IsDBNull(SelectName.Items.FindByValue(value)) Then....
I cannot add any more code than that, Apologies
After updating the question by add code, I think the available options are limited:
Create an extra Javascript method, that stores the selected values in a json object and store it into a hidden input field. I'm not an expert in asp.net, though I'm sure there exists a method to parse json objects from a string.
Create an extra javascript method, that concatinating all values to a String and store it into a hidden input field. With creation of a single string, you can define your own delimiter.
After that, add this extra Javascript mehod to the event onSubmit. Then submit the form and read the value from hidden input field.
P.S. In my eyes the second idea is more simple to create, than the first one. And maybe there are better ways.

Mysql multiple line requests

I'm new to MySQL and I am facing a little problem that I couldn't find an answer to in any previous thread here, so I was hoping someone could help, okay here it is:
When typing a request on mysql (on the terminal) you can just press enter to make it stand on many lines instead of one, but how do you get back to a previous line ?
I tried the arrow buttons and it didn't work, neither did the backspace button, any help is welcome, thank you in advance!
The mysql command uses the readline library. Each input line is edited independently, so once you press Return you can no longer go back and modify that line. The arrow keys will recall the line, but it's inserted into the current line being edited, and appends to the query.
So the solution is to NOT press Return until you've finished typing the whole query.
If you mean to show previously entered lines in order to send them again, according to the MySQL website, it should work via the up/down keys.
[...] the up-arrow and down-arrow keys move up and down through the set of previously entered line
http://dev.mysql.com/doc/refman/5.0/en/mysql-tips.html

edit phpmyadmin blob field

Huh.
In the same vein as Viewing Content Of Blob In phpMyAdmin, i have a blob.
And just like in the screenshot of the given url, it says "blob". Thanks, phpmyadmin! You're the best!
Unlike the chap who asked the question above, though, I really want to edit the blob values, and then save them. So, if my blob has, as its text "ima blob yo" - and I can see that text, thanks to the solution given above - how do i edit that to "i am a blob, you".
I don't particularly want to upload a text file each time i edit a blob, that's totes bogue. Just want to edit it, as i would a text field.
cheers!
Ah. the phpmyadmin site, there this page: http://www.phpmyadmin.net/documentation/#faq1_31
$cfg['ProtectBinary'] boolean or string
Defines whether BLOB or BINARY columns are protected from editing when browsing a table's content. Valid values are:
* FALSE to allow editing of all columns;
* 'blob' to allow editing of all columns except BLOBS;
* 'all' to disallow editing of all BINARY or BLOB columns.
Ok, so that details how to allow me to edit my blobs.
I made the change
$cfg['ProtectBinary'] = FALSE;
$cfg['ShowBlob'] = TRUE;
and put these two as the last lines in my config.inc.php file, which, because i'm using UBUNTU and used the auto install sudo apt-get install phpmyadmin, was at /etc/phpmyadmin/
And everything worked, kinda. I can now edit my blobs... with the limitation that phpmyadmin shows the current contents of the blob in "blob-view", which is a whole bunch of numbers or some nonsense.
Simple solution i found was to:
write over the text. Simple editing isn't really an option, but luckily i didn't need to edit, just add in new data.
change the "function" option from ... i cannot remember what it was, but it was something crazy... to just "blank". That's the same kind of blank as the function option defaults for other values - ints etc
cheers,
andrew
PS that
$cfg['ShowBlob'] = TRUE;
was from the given url in the question i linked to. The poster states it isn't effective in phpmyadmin, but i only downloaded using a latest sudo-get a few months back, so it still works. Actually, i needed to put that value in to get editing to work.
I'm using phpMyAdmin v4.6.4. I find an option on GUI to set this config.
You can click on Home button. Then click on Panel Appearance settings.
In this screen, click on Main panel tab, then Edit mode tab.
After that, select 'no' in Protect binary columns dropdown.
Edit mode tab
If your BLOB field is really only text, then you might consider converting your BLOB field to a TEXT field (there should be no loss of data in the process). TEXT fields are viewable/editable directly from phpMyAdmin.

separating values in a URL, not with an &

Each parameter in a URL can have multiple values. How can I separate them? Here's an example:
http://www.example.com/search?queries=cars,phones
So I want to search for 2 different things: cars and phones (this is just a contrived example). The problem is the separator, a comma. A user could enter a comma in the search form as part of their query and then this would get screwed up. I could have 2 separate URL parameters:
http://www.example.com/login?name1=harry&name2=bob
There's no real problem there, in fact I think this is how URLs were designed to handle this situation. But I can't use it in my particular situation. Requires a separate long post to say why... I need to simply separate the values.
My question is basically, is there a URL encodable character or value that can't possibly be entered in a form (textarea or input) which I can use as a separator? Like a null character? Or a non-visible character?
UPDATE: thank you all for your very quick responses. I should've listed the same parameter name example too, but order matters in my case so that wasn't an option either. We solved this by using a %00 URL encoded character (UTF-8 \u0000) as a value separator.
The standard approach to this is to use the same key name twice.
http://www.example.com/search?queries=cars&queries=phones
Most form libraries will allow you to access it as an array automatically. (If you are using PHP (and making use of $_POST/GET and not reinventing the wheel) you will need to change the name to queries[].)
You can give them each the same parameter name.
http://www.example.com/search?query=cars&query=phones
The average server side HTTP API is able to obtain them as an array. As per your question history, you're using JSP/Servlet, so you can use HttpServletRequest#getParameterValues() for this.
String[] queries = request.getParameterValues("query");
Just URL-encode the user input so that their commas become %2C.
Come up with your own separator that is unlikely to get entered in a query. Two underscores '__' for example.
Why not just do something like "||"? Anyone who types that into a search area probably fell asleep on their keyboard :} Then just explode it on the backend.
easiest thing to do would be to use a custom separator like [!!ValSep!!].