I'm new to PHP and MySQL and I'm currently working on a project where I need to query my MySQL database using the `mysql_query` function in PHP. I'm facing an issue where the function doesn't seem to work when I pass a variable as the query. Here's an example of the code I'm using:
$query = "SELECT * FROM my_table WHERE column = '$my_variable'";
$result = mysql_query($query);
The problem is that when I run this code, I don't get any results in `$result`. However, if I hardcode the query directly into the `mysql_query` function like this:
$result = mysql_query("SELECT * FROM my_table WHERE column = 'some_value'");
Then I do get the expected results. I have verified that `$my_variable` contains the correct value by using `echo`.
Am I doing something wrong? Is there a different way I should be passing variables to the `mysql_query` function? Any help or guidance would be greatly appreciated.