Hi,

INSERT INTO person (name, surname, fk_accessid) values ('$name', '$surname', SELECT id FROM access WHERE name = '$uid' AND psw = '$psw')

Hi above code doesn't work. Is there such thing thou?

EDITED:
Note: I meant to open this in Mysql forum but I cannot move it now.

Try

INSERT INTO person (name, surname, fk_accessid) values ('$name', '$surname', (SELECT DISTINCT id FROM access WHERE name = '$uid' AND psw = '$psw'))

Although I would prefer something like -

$msquery = "INSERT INTO person (name, surname, fk_accessid) values ('" . $name . "', '" . $surname'" . ", SELECT DISTINCT id FROM access WHERE name = '" . $uid . "' AND psw = '" . $psw . "') ";

and then use $msquery in place of your SQL string literal.

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.