sorry about this noob question, but i am new to PHP. i created a databse in PHPmyadmin to handle IP adresses and was wondering what type should it be ( int,varchar.etc.) i will be using

$referrer = $_SERVER; to compare the database to this. i was also wondering if there is a command in PHP that will tell me if a variable is in a string. i no there is a matching command but i think that looks for exact matches rather than is in the string or not.

i also have one last question, if i have a list of string an easy way to upload them to a database..

any suggestions

Thanks for the help. sorry there NOOB questions.

To start, HTTP_REFERER is not an IP address, but the URL of the page that sent the client to the current page. You need to use REMOTE_ADDR to get the users IP address (And just so you know clients can hide their IP address behind a proxy which will give you inaccurate results, but you shouldn't worry about that). To store IP addresses in a MySQL database I use varchar with a length of 15 characters (Which is the length of the longest IP address possible 255.255.255.255).
To determine if the value of a variable is inside a string I use:

if(strstr($string, $value)) echo "Found '".$value."' in the string.";
eles echo "Didn\t Find '".$value."' in the string.";

Where $string is the string to search and $value is the value to search for.

And I'm assuming that you poorly-worded last question is asking: what is an easy way to upload an array of strings to a database? I would create a separate table with a row for the array number (A number unique to each array), the element position in the array, and the string. This way adding arrays is easy (Just find the unique array id and insert each string with the array id and the string position), and searching is a breeze.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.