Please correct my syntax:

im including a file with the following constants

define('IPADDRESS', 	$_SERVER['REMOTE_ADDR']			);
define('BROWSER',		@$HTTP_USER_AGENT				);
define('REFERER',		@$HTTP_REFERER					);

if i echo IPADDRESS; i get the ip address (127.0.2) so the include is fine.

My mysql instruction is as follows:

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

The above inserts the value IPADDRESS into the database!

I have also tried the following but no success:

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

What have i done wrong? first time im using constants in mysql_query.


I also have the following questions if you have time,

1. ive seen syntax like "something::something", i cant find anything for "::" under php operators

2. the function session_set_save_handler(), does it store in a database on the server or on the clients machine? as this always seems to be an advised solution if cookies are disabled on the clients machine

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.

I dont understand what you mean by:
you could never write the word IPADDRESS in a string without having it replaced by it's definition.

I tried {curly braces} and it did not work

You were right regarding the syntax of the second query and it worked, but only after changing IPADDRESS to IPAD, so i guess the word IPADDRESS cannot be used for some reason!

Thanks for the help!!!
I am marking this thread as solved but if you can give me some pointers as to what just happened regarding IPADDRESS, please PM me, thanks again

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.