Single quotes getting doubled every time i send message in php [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I encounter a strange problem, every time i run my script in php (send a message) and i add a single quote ' it get's doubled. Example sentence: I'd like to know php on expert style it outputs on the one that receive the message: I''d like to know php on expert style. After i reply they are getting doubled again I''''d like to know php on expert style`. What could be the problem?
My file that sends the message looks like this http://pastebin.ca/2495116
and the variable that send the message from what i can see is $m_message
My file that echo's received message looks like this http://pastebin.ca/2495115
This is the variable where the message is being kept and echo'ed on the screen:
<?php echo "" . replace($fetch->message) . ""; ?>

$m_message=str_replace("'","''",strip_tags($_POST['m_message']));
This is what you're looking for.
str_replace(): http://tz1.php.net/manual/en/function.str-replace.php
Changes "'" to "''" every time it finds one in the string strip_tags($_POST['m_message'])
How you ideally want to solve that problem is entirely up to you.

Related

php variables GET [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I am stuck on getting something working. Basically I want to be able to do file.php?ip=132.123.123.123&port=28005
basically i want filegetcontents to embed the text
is what I want (Shows offline because of syntax error because I Can't get the when its online it returns in plain text online / offline
Print "<td>".file_get_contents("http://www.domain.com/status.php?ip=".$ip?port=.$port);" </td></tr>";
its grabbing from the database the ip and the port and the status checker checks on file.php?ip=132.123.123.123&port=28005
Below doing it I get this error
[03-Jan-2014 03:46:14 UTC] PHP Warning: fsockopen() [<a href='function.fsockopen'>function.fsockopen</a>]: unable to connect to udp://123.123.123.123?port=28035:0 (Failed to parse address "123.123.123.123?port=28035") in /home/*/public_html/servers/status.php on line 5
The line im using
Print "<td>".file_get_contents("http://www.domain.me/servers/status.php?ip=".$info['ip']."?port=".$info['port']) ." </td></tr>";
You have multiple quoting issues and an erroneous semi-colon:
Print "<td>".file_get_contents("http://www.domain.com/status.php?ip=".$ip?port=.$port);" </td></tr>";
should be
Print "<td>".file_get_contents("http://www.domain.com/status.php?ip=".$ip."?port=".$port) ." </td></tr>";
A decent text editor would have caught the quoting issue and an IDE would have caught the semi-colon issue.
As for creating the table, that will depend on the format of the data you get back from file_get_contents(). Do a var_dump() on that data and see what format it is in so you can plan how to approach making your table.
$data = file_get_contents("http://www.domain.com/status.php?ip=".$ip."?port=".$port);
var_dump($data);

How do I get information from this page, that isn't in the HTML code [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
http://www.aliexpress.com/item/NEW-7-Android-2-3-256MB-DDR2-4GB-NAND-Flash-7-inch-tablet-pc/498159194.html - I got this link
Here you can see a buttons: bundle, color
If you click some of them the price will change, but the question is how can I parse that behaviour to my page via php?
The problem is that I can't understand where is javascript code that executes this, or how to find it, maybe someone got ideas about that?
Inspecting that page's source code I can see that the skuProducts variable in javascript contains this information encoded into a JSON-string. You can't really run this javascript code on your webserver, so you'll have to devise another way to get that variable's value - and then you can use json_decode() to get the contents.
Note that changing the amount of items results in an AJAX call to a shipping costs calculator. You could probably simulate that, but I'm not sure that webshop would like that (and it might be illegal).

Do I need html tags to do carriage returns? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm working on a problem whereby identical output is being presented differently on an html page. If I have;
Test
Test
as an entry in a database table, one part of my page will permit the linespaces (which I want), but another part of my page will not and just cut out the spaces, making them look like
Test Test
Can someone help me to identify possible issue?
Yes, you do. Unless you've got some CSS and/or <pre> tags to force HTML to honor line breaks, they're generally treated as whitespace. To get a "line break" in HTML, you have to use a <br /> tag.
(I'm not sure to understand)
You must convert the \n in <br/> (use function nl2br() if you are in php)

counting the number of times a script is executed [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have got two php forms - question.php and marks.php. I want that each time question.php submits its values to marks.php , the variable $total in the form marks.php be incremented. I have tried using static variable but still am not able to get it done!
Nothing "inside PHP" itself will persist anything across different page loads. You need to store the value somewhere "external", e.g.:
write it to a file
write it to a database
store it in a memcache or other kind of cache
send it to yourself in an email
burn it into the screen of the computer and use an elaborate video camera and OCR setup to read it back
...
maybe: sessions

How to know if an variable exist in url even thou it dont have any value in php [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Previously I used to add an value like ?help=1 to make PHP know that variable help is used and now it has to show help page. But on a few sites, I have seen they simply use only variables and do not assigned any value (i.e just ?help). Can you please tell me how to do it?
What's wrong with isset($_GET["help"])?
Use PHP's isset function:
if(isset($_GET['help']))
{
echo $_GET['help'];
}
else
{
echo "help is not set";
}
This just means the variable 'help' exists, but has no value. If you maybe left a field blank on a form, it may do this simply so the next script can acknowledge it has no value rather than ignored. It works exactly the same way.

Categories