Insensus 52 Junior Poster

The first attempt doesn't work because if it WOULD work, you could never write the word IPADDRESS in a string without having it replaced by it's definition.
What might work but of which I'm not sure is using {IPADDRESS} instead of just IPADDRESS.

And in the second attempt you didn't get the quotes at the end right.

$update = mysql_query("UPDATE login_errors SET tries = '$addtry' WHERE ip_address = '".IPADDRESS."' ") or die(mysql_error());

1. The :: means that you're accessing the member function of a class definition without an initialized class (so this is not definied)

2. I've never seen session_set_save_handler before but from what I just read it appears that it enables you to define your own way of saving a user's session data, so you could save it in a database but not on the client's machine.

Insensus 52 Junior Poster

If you look at this page http://www.cplusplus.com/reference/algorithm/find/ you'll see that find() requires the == operator to be defined on your class, and it's not.

Something like this probably:

bool A :: operator ==(const A &t) const
{
	return ((x == t.x) && (strcmp(name, t.name) == 0));
}

On a side note, why did you define putData() as a member-function of A even though it doesn't do anything with the A it's called from?

And why does getData() take an argument which it doesn't use?

Insensus 52 Junior Poster
output.open("TEMPS.DAT", ios::in);
output << temp[counter1] << endl;

Do not make sense as you are trying to write to an in-stream.

This should be what you're looking for:

output >> temp[counter1];
Insensus 52 Junior Poster

Quote from cpp reference:

'Allocates a block of size bytes of memory, returning a pointer to the beginning of the block.

The content of the newly allocated block of memory is not initialized, remaining with indeterminate values.'

Insensus 52 Junior Poster

You've misplaced the parenthesis in this line:

if(strcmp($line,$name == 0)) {

Should of course be:

if(strcmp($line,$name) == 0) {
Insensus 52 Junior Poster

You're missing an ending double-quote here.

$servicesoffered="<br/>"."$edit_servicearea_str<br/>\n$detailedmsg<br/>;
Insensus 52 Junior Poster

In the first file $cid is never defined.
I think you mean $_POST instead of just $cid?

Insensus 52 Junior Poster

And just because I have it finished now anyway, here is what I just made. :P

template <typename T>
T switchEndian(unsigned char * from)
{
	T tmp = 0;
	for(unsigned idx = 0; idx < sizeof(T); idx++) {
		tmp += (from+(sizeof(T)-idx-1))[0] << idx*8;
	}
	return tmp;
}
long result = switchEndian<long>(&foo[6]);

It might be bad code though so I'm not very skilled.

Insensus 52 Junior Poster

Is reversing the vector an option?
I guess this should work:

reverse(foo.begin(), foo.end());
long some_long = *(long *)&foo[0];
Insensus 52 Junior Poster

That's because an array is nothing but a pointer to the start of a memory block, so

cout << array << endl;

will print the memory address of the start of your array.

To print the whole array you should iterate over the 'rows' (first index) and print each array these rows define.
(Note: this still sends a pointer to the cout but since this is just a char * it will print all the chars in that bit of memory.)

Also, this explanation isn't perfect but it should at least make you see what's happening and why.

Insensus 52 Junior Poster

This simply means that the $var you're trying to split doesn't contain any | at all, therefore the resulting array ($tmp) is only 1 element long and $tmp[1] doesn't exist.

Insensus 52 Junior Poster

The dereference (*) operator has lower priority than the member (.) operator so you need to add brackets:

(*str).length()
Insensus 52 Junior Poster

What rubberman said is actually wrong.
In a multiset an element's key is itself so you need to specify only one type.

Now I'll try to explain to you why you get this error:
When you use a function that's defined from a template, your compiler will at compile-time create an actual function from your template definition for the required type.
Now because your instantiation happens with an int the multiset inside your function will be a multiset<int> and therefore multiset<int>::insert(const string&) will generate an error even though you will be preventing that statement from ever happening at run-time. Your compiler can't know that and therefore can't compile.

You COULD do this with templates, but then you'd need to create a new specialization for every different type of variable which is pretty much the same amount of work as just making three different functions.

Insensus 52 Junior Poster
long2ip();

:P

dalip_007 commented: excellent +2
Insensus 52 Junior Poster

http://php.net/manual/en/function.header.php

This lets you change the HTTP headers which is probably the best way to redirect someone.
Something like:

Header("Location: /$directory");

Be sure to put it early in your document, before any output is generated, or you will get an error because you can't change the headers anymore.