Jump to content

Can you insert defined() constant into database?


DamienRoche

Recommended Posts

I'm having trouble inserting constant into database.

 

Here are the relevant lines:

 

define("IP", clean($_SERVER['REMOTE_ADDR']));

 

mysql_query("INSERT INTO sessions (user,ip,sid) VALUES ('$user','IP','$sid')") or die(mysql_error());

 

Obviously, it is insert 'IP' into database and not the constant value. Is there a way around this....

 

on a more important note - with the use being evident - am I going about this the wrong way?

 

Thanks.

PHP does not parse constants within strings, you'll have to concatenate it

mysql_query("INSERT INTO sessions (user,ip,sid) VALUES ('$user','".IP."','$sid')") or die(mysql_error());

 

I thought that was concatenating it. Could you elaborate?

 

Thanks for the help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.