I've come across an issue where my one query in PHP for my mySQL database is not returning anything. The query works when using the mySQL database, and I'm assuming in my php file, but does not print out anything, and returns as a false value. Any help or tips/tricks you can give me is appreciated, I haven't actively used SQL in about a year, and I'm trying to learn as much PHP as possible in a very limited amount of time, so my syntax is probably not correct. I know my database is connected.
The following code works further up in the program.
$patIDQuery=("SELECT ID FROM patients WHERE usernam3='$myusername'");
$patientID=mysqli_query($db, $patIDQuery);
$row=mysqli_fetch_assoc($patientID);
$user = $row['ID'];
$_SESSION['myUserID']=$user;
In mySQL, this code works, and I am trying to get the same result.
SELECT medications.CLINNAME FROM medications RIGHT JOIN patientData ON patientData.medID=medications.medID WHERE patientData.ID='*the actual patient id*';
Code with an issue
<?php
$clinNameQ=("SELECT * FROM medications RIGHT JOIN patientData ON 'patientData.medID'='medications.medID' WHERE patientData.ID='$user'");
$clinName=mysqli_query($db,$clinNameQ);
$rowClin=mysqli_fetch_assoc($clinName);
$clinicalName=$rowClin['CLINNAME'];
echo $clinicalName;
?>
I've been messing around with '' and "", but nothing seems to have been working. I'm wondering if there is an issue with backslashing, or if it is (what I think it is), an issue with the fetch.
Help is so much appreciated!