I've been encountering this problem for a while now and I have no idea how to solve it. There is this "guestbook" that I made where people write a message and it prints out under the form. So a normal guestbook. But it sometimes strips messages from a certain point onward. Let me explain - they write something like "It was amazing, incredible, awesome performance, that should be repeated more and more." and the guestbook shows only "It was amazing, incredible, awesome performance". I have no idea what is wrong with the code nor what characters make this happen, but every now and then I see incomplete messages with a following message that says something like "The message was not send completely." and then summarizing of their previous stripped one.
nl2br(addslashes(htmlspecialchars(stripslashes($_POST['message']))))
This is the code that I use for editing messages before inputting them into the database. I took a look into the database and the messages are already stripped, so there is probably a problem with sending or editing the message rather than with printing it out of the database.
People are able to write full paragraphs that end up unstripped, so it's not a problem that occurs to everyone and everytime. There are currently about 50 messages and only 2 of them are stripped, so the stripped ones make like 4% of them all. Are there any characters that the people might eventually be using that cause the unwanted stripping? May there be a problem on the users' side? Or is there a problem with my code?
Thanks for help and any ideas in advance.
Thanks #FlashThunder for your idea with a log, I found out that the characters that strip the messages are emojis such as 😍. When an emoji occurs in a message, it gets deleted and stripped from that point onward. Thanks for you help!
Related
How are you?
I have a problem with the output of an internal webpage I use to print a query. It is ultimately just a formatting problem with the output.
The actual script (get_data.php) should do nothing more than to create an output for a certain topic or for a certain category (for example, records with the value "DVD" or books of an author).
That's exactly what it's supposed to do.
Now I have the problem that when I create the output this is not displayed correctly.
The actual text block sits one line below the bullet point. This is not earth-shattering but it does not look quite so pretty, so I would like to fix it. ;)
The website uses some stylesheets to give it their formatting, but the bullets or the list are generated by script. But I'm standing in front of the mountain and can not continue with this "formatting problem".
Can you help me?
Many thanks in advance
Dennis
PS: I hope my english isn't to bad.
I have a function that enables members on a site to message each other; the message is stored in a MySQL database. When a member sends a message to another member, I want to keep the natural flow of the message, i.e with white space and paragraphs etc. However, these are removed when the message is stored in MySQL.
I am aware that there is a PHP function that allows this to happen, but I am not sure what it is. Below is an example of what I am referring to. I hope it offers better insight to what I mean.
An example message:
dear Tom
thank you for contacting me.
the details are here.
The above example has 3 seperate lines with white space. However, it is rendered as follows in the MySQL table:
dear Tom thank you for contacting me. my details are below.
Can somebody please tell me what the PHP function is that will allow it be be rendered naturally but still escape unwanted values.
nl2br is what you're looking for.
But don't use it before inserting to the database. Use it in the presentation layer.
The database will contain the message as entered by the user. Then you can choose how to display it later.
With <br> tags:
<p class="message"><?=nl2br($message)?></p>
Or perhaps in the future you might want to use a <pre> tag instead:
<pre><?=$message?></pre>
Note the absence of the call to nl2br in the pre. I know you don't wish to display it in a pre tag for now, I'm just using it to demonstrate the point.
I know there is a message saying this cannot be done. However, I don't know which year the question was asked and reCaptcha may have been modified since then. Sometimes a numeric image is displayed already. I'd like to make all images similar.
You can look at the following URLs. This might help you
http://googleonlinesecurity.blogspot.com/2013/10/recaptcha-just-got-easier-but-only-if.html
http://code.google.com/p/recaptcha/wiki/HowToSetUpRecaptcha
EDIT:
For those having issues with mysql data that won't get rid of white spaces between rows. It's because of deep tabbed indents due to an issue when copy pasting from editors/word documents.
http://bugs.mysql.com/bug.php?id=49611
Here is the bug that doesn't allow me to fix this issue, it's because of deep indents, it's a MYSQL bug that won't be fixed.
PS: Message to community, Thanks to the guys that downvoted this question without giving time to properly formulate the issue. It's a debug process, you can let people know if you need something instead of acting rude and attacking the questioner, after all as the poster I'm likely to read and see what you need. If I knew what was needed to diagnose the issue, I would've found it and would not be posting here. Since I posted here, it means I don't know where to look as to identify if the issue is a MYSQL one or a PHP one. Be polite with your community guys, don't act like wolves trying to bite someone's head off all the time because they didn't give you everything you wanted right off the bat.. Take care.
Here is the raw paste from the database:
one two three
one two three
one two three
one two three
one two three
Why is it still being like this? I str_replaced 's and \n\n\n's . I don't want to get rid of 2 \n's due to the format of the text I need in between the text.
The result I'm looking for is :
one two three
one two three
one two three
one two three
Meaning max 2 \n's.
This might be what you are after:
$normalized = preg_replace('~(\r?\n\r?){3+}~', "\n\n", $original);
But hey, it's hard to say. You want to keep stack overflow a happy place, you put some effort to posting a question.
I have a image slideshow each image sliding after 4 seconds and a message is displayed at end of each slide. I could record the message when button is clicked but couldn't record the message at the end of each slide if button is not clicked.
Here is my code:
and I also want to display random images without repetition. Can anyone help me with this?
Thank you,
Try to add second parameter to mysql_fetch_array eg:
mysql_fetch_array($result, MYSQL_ASSOC)
or use mysql_fetch_assoc instead.
This is just a general answer, but hopefully it can help you a bit. In your question, you posted a whole bunch of code for us to deduce the problem. This is both a good thing and a bad thing. It is good because you have posted enough information for us to be able to help you and figure out what is going on.
However, it is also bad, not in the sense that you are doing something bad, but in the sense that it is highlighting where you are having your problem solving this issue. Again generalizing, problems with code are usually simple in nature. They become complex because of the complexity surrounding and obscuring them. In order to help you with this problem, and in order to help yourself (both in general and in this case), you should start by narrowing down the scope of where the problem occurs.
For instance, in your question, you say you have an issue recording a message. However then you say "I could record the message when button is clicked. " So you have introduced a new variable into your question without telling us about the button. So we aren't sure anymore if you are having an issue with the button, or with recording the message.
So what I am saying is, narrow down your problem, and nail it down. You should be able to make a solid statement like this: There is a button, that when clicked should record a message. However, when my application moves a slide from one to the next, the button no longer works. In order to do this, you will need to define exactly what behavior you are trying to make happen. Even if this isn't a formal project, you should make a use case (even in notepad is fine) where you exactly describe what functionality you are trying to make happen (implement). You will then be able to exactly describe how your code is not doing what you said you want it to do.