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);
Related
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.
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 to display data consisting of approx. 1000 character.
Right now, I am using a text file and fetching it from there line by line till end of file and displaying it through AJAX.
But its quite slow.
I wanted to know if i store that data in database as text would it make difference ?
Yes. It does depend on how many lines there are tho. If there aren't many lines, it won't make much of a difference.
I would recommend (for something small) a txt file on the server and directly getting it directly with AJAX, without the addition step of php and sql.
You shouldn't need to read line by line. You can read the full string with:
file_get_contents('/path/to/file')
I cannot foresee storing the text in a single database row/field will improve efficiency at all.
actually storing text in database can slowdown performance, looks like your problem is in line-by-line reading, read about file_get_contents or file or the best way readfile
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 got it from MaxMind
And this is how the data looks like:
Country,City,AccentCity,Region,Population,Latitude,Longitude
ad,aixas,AixĂ s,06,,42.4833333,1.4666667
ad,aixirivali,Aixirivali,06,,42.4666667,1.5
ad,aixirivall,Aixirivall,06,,42.4666667,1.5
ad,aixirvall,Aixirvall,06,,42.4666667,1.5
ad,aixovall,Aixovall,06,,42.4666667,1.4833333
ad,andorra,Andorra,07,,42.5,1.5166667
I want to convert the structure of this unknown type data into MySQL query language so that I can insert it into my MySQL database. Is it possible?
The data is about 145 MB!! I can paste the whole data code if required.
Alternative required solution: What should I do to insert it in my database?
that looks like a regular CSV to me, and PHPMyAdmin is capable of handling such format in the import menu
The problem I see there is that you've got a large file to upload and most php configurations won't allow you such big upload. Why not try it with, say, the first 1000 lines of your file?
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
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am a new user of php.
I have one table in mysql database. I have a form which the users use to query the mysql database. I am testing my html form page on my linux laptop which has APACHE server.
I am able to make a connection to the mysql database and display results in the browser.
I am not sure how to capture the results from the variable which has query results which has several rows of data and be able to write the results to a text file in /var/www/
Thank you
I noticed every time you check if the POST variable is set you use something like
if(isset($POST["submit"])){
Was that a typo in this post or are you forgetting the underscore?
if(isset($_POST["submit"])){
Also try to use mysql_fetch_assoc instead of mysql_fetch_array.
And always prepare the variabes for usage in a query if you do not want to get hacked instantly.