[SOLVED] Getting User ID from Chat Username |
7/18/2021 12:09:44 AM |
General Tips and Tricks | |
D
DRCR Dev author
Hi In the Chat template, a snippet gets the username of the current chat using echo $_SESSION["currentUserName"]; I am trying to add a button next to the username to redirect to the profile of the user which is found at https://website.com/profiles/%ID% I've created a button, in the server code I have: $chatuser = $_SESSION["currentUserName"]; And the client after: location.href='https://website.com/profiles/'+result["ID"]; But I cant get the button to work. Any ideas on how to get user ID from the username? -Cec |
|
A
|
acpan 7/18/2021 |
Try to ensure your SQL returns value. A few things:
if you want to use PreparedSQL, should be like this with parameterized placeholder: $sql = DB::PrepareSQL("select ID from users where username = ':session.currentUserName' "); // save and pass the DB error to client after event OR use simple DB::Query $chatuser = $_SESSION["currentUserName"]; if ( DB::LastError() ) { // pass the sql to your after client code to print it out for troubleshooting: Then at the Client After, console.log the 3 parameters passed. hope it helps. |
D
|
DRCR Dev author 7/18/2021 |
Thanks. This gave me the error and I was able to solve the query. -Cec |