[thelist] PHP help required please

Dave Stevens stem at stemofficial.co.uk
Sun Feb 3 15:30:00 CST 2002


No, the cookie is not in a function, nor am I reading it from within a
function.
and I am using PHP4 as a module, on a virtual server, remotely hosted.

setcookie("LOGININFO", "$username");

thats the code that sets the cookie when it is told to set it in an if
statement.
I then want to be able to use the value of $LOGININFO like so:

$sql = "INSERT INTO  '$LOGININFO' (prod_id,prod_name,prod_price) VALUES
('1','2','3')";

as I have a separate table for each user. so what I need it to do is produce
the value of $LOGININFO where it is referenced. For example, if I had logged
in as username dave, I want the code to produce:

$sql = "INSERT INTO dave (prod_id,prod_name,prod_price) VALUES
('1','2','3')";

the tables are created during the registration process, so they are already
there before this code is executed.

thanks for help so far, you are all very helpful!
cheers,
Dave Stevens


> Are you trying to read the cookie from within a function? You'll need to
write:
>
> global $HTTP_COOKIE_VARS["username"];
>
> near the top of the function. Or, if you're using php 4.1.0 or
> higher, then you can access this via $_COOKIE["username"] which is
> always global in scope.





More information about the thelist mailing list