php

Test if port open and forwarded using PHP

Full Disclosure: There's a similar question here. Is there any way I can test if a particular port is open and forwarded properly using PHP? Specifically, how do I go about using a socket to connect to a given user with a given port? An Example of this is in the 'Custom Port Test' section of WhatsMyIP.org/ports. ...

Optimising a haversine formula SQL call in PHP

I'm creating an MySQL call using PHP, I'm calculating distance using the haversine forumula: SELECT name, id, (6371 * acos(cos(radians(' . $lat . ')) * cos(radians(geoname.latitude)) * cos(radians(geoname.longitude) - radians(' . $lon . ')) + sin(radians(' . $lat . ')) * sin(radians(geoname.latitude)))) AS distance ...

Too many connections to DB preventing some queries from executing.

I have an issue where users on my web site have recently begun to receive the error message: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) I know that the connection strings in the code are correct, as users are able to query the database view pages that retrieve info from and submit user-generated...

php using CURL to grab whois record

Example: http://www.whois.net/whois/hotmail.com When open in browser, output is shown. When using curl call, it show nothing. What's wrong? I want to return whole page result, then use regular expression to retrieve data at Expiration Date: 29-Mar-2015 00:00:00 line. $postfields= null; $postfields["noneed"] = ""; $queryurl= "http://...

add values from arrays to an array?

how do i add values from arrays to an array so that it grows by time. eg. all values form array1 to myArray. all values form array2 to myArray. so now myArray contains all values from 1 and 2. i want to do this in a cpu efficient way ...

What's happening when we use mail() in PHP?

<?php mail("[email protected]", "My Subject", "Line 1\nLine 2\nLine 3"); ?> We don't need to specify the email/password/mail server address && port,but it can be sent . ...

Report xss/injection attacks by email (how to encode)

I have a form to singup yourself in a mailing list. I had set up the script to send me a mail for every singup and confirmation. The last days I saw a bunch of empty submisions (rejected). Turns out filter_input is that good :-) But I want to see the input of the malicious users, so I'm encoding the input and sending it to me by mail ...

jquery load php file - result is not complete

I'm trying to load or better reload a DIV with content from an included php file. so the file is included in the webadmin.php from the location webadmin/pages.php. Then i alter some data in the DB through serializing. Now I would like to reload the pages.php from the callback of the serialize POST with load();. This all works fine up u...

How to you insert into MySQL database and returns its id in PHP PDO?

Is there a way to insert into MySQL database using PHP PDO and return its id? Or I will just have to search fot its id after insertion? ...

MySql cache problems... some questions

First of all, I am using PhpMyAdmin, is this okay or not? Because when I have cache disabled, and do two queries after eachother, the second query always is faster, so I am thinking maybe there is an internal cache on PhpMyAdmin? Secondly, is there any way to get the time of how long a query takes, into php, and echo it onto the browser...

Is there really no way to programmatically click a link using PHP?

I have been trying for a while now trying to figure out how to programmatically click a link using PHP and/or javascript. I have it setup so if the user clicks a link it will refresh a table. You don't really need to know why I want to do this b/c then it will go down a whole long road of confusion. Just know that there is a link to be c...

query_cache_min_res_unit; What is it and what does it do?

I am setting up cache in MySQL. Could someone please explain query_cache_min_res_unit? What does it do etc? I have read the manual and it doesn't explain so good. Details are appreciated... Or examples... Thanks ...

Are there any difference between regular expressions in javascript and PHP?

This is the regex to validate email address in javascript,I'm not sure if I can just use it directly in PHP: /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\...

Determine if a character is alphabetic

Hello, Having problems with this. Let's say I have a parameter composed of a single character and I only want to accept alphabetic characters. How will I determine that the parameter passed is a member of the latin alphabet (a–z)? By the way Im using PHP Kohana 3. Thanks. ...

PHP FPM returns HTTP 500 for all PHP errors

I am running nginx with PHP-FPM. My nginx configuration for handling php files looks like this: location ~ \.php$ { set $php_root /home/me/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $php_root$fastcgi_script_name; include /etc/...

save page in php

Hi all, I am writing a web program using mvc php framework. I have index and another view which I want to render the view inside of my index. First I call view then I call index and put view into it. My problem is I want to save the whole view into a variable and do something like echo $view in my index. both require_once and include_onc...

PHP Mysqli inserting a row to a table with auto_increment column

Im working on a table that has 4 columns and the first one is an auto incrementing integer called id. If im going to insert into this table using mysqli prepared statements I keep having trouble inserting a query that works. Using PHPmyAdmin It tells me to give it NULL. Ive tried this: $query = "INSERT INTO tbl (id, col2, col3, col4) V...

PHP5 UTF-8 encoding error - PHP4 works fine

Hey, i'm having some troubles with UTF-8 encoding on a website. Calling my script using PHP5 all the umlauts (ä, ü, ö,...) look like this: ökflödsköl Calling the script using PHP4 shows everything as expected... both php.ini look the same an so my question would be: is there an other file where i can change the output encoding? T...

PHP Regex to grab {tag}something{/tag}

Howdy, I'm trying to come=up with a regex string to use with the PHP preg functions (preg_match, etc.) and am stumped on this: How do you match this string?: {area-1}some text and maybe a <a href="http://google.com"&gt;link&lt;/a&gt;.{/area-1} I want to replace it with a different string using preg_replace. So far I've been able to...

PHP: Server duplicating $_SESSION['Name'] data to '$Name' variable

I've just discovered a setting on the server I'm developing a site for that is different from my localhost settings, however, I can't track down where to change it. Here's a simple example of what's happening. $_SESSION['Animal'] = "Dog"; echo "#1: ".$_SESSION['Animal']."<br/>"; echo "#2: ".$Animal; On my localhost, the server return...