GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Tech Session Name in SQL query? (https://gfy.com/showthread.php?t=1359524)

Publisher Bucks 11-23-2022 10:27 AM

Session Name in SQL query?
 
What is the best way to include
Quote:

<?=$_SESSION['name']?>
into an SQL query please?

I want to do something along these lines (which isnt the correct way apparently lol):

Quote:

$con=mysqli_connect("localhost","USER","PASS","DB" );

$result = mysqli_query($con,"SELECT * FROM Documents WHERE Writer REGEXP '<?=$_SESSION['name']?>' ORDER BY ID DESC;");

while($row = mysqli_fetch_array($result))
Basically, any time one of my writers logs into the admin system, I want it to display the documents they've completed based on their login name to them and I figured using the session name would be the easiest way, as it gets attached on submission and stored in the DB in the 'Writer' column, I just can't figure out how to get that info to display on a page through an SQL query :Oh crap

k0nr4d 11-23-2022 10:37 AM

Exactly the same way as any other variable

$result = mysqli_query($con,"SELECT * FROM Documents WHERE Writer REGEXP '".mysqli_real_escape_string($con, $_SESSION['name'])."' ORDER BY ID DESC;");

Publisher Bucks 11-23-2022 12:44 PM

Quote:

Originally Posted by k0nr4d (Post 23064930)
Exactly the same way as any other variable

$result = mysqli_query($con,"SELECT * FROM Documents WHERE Writer REGEXP '".mysqli_real_escape_string($con, $_SESSION['name'])."' ORDER BY ID DESC;");

Ah okay, I was using the same as in my HTML code, thanks for clearing that up for me man :)


All times are GMT -7. The time now is 10:27 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc