codeeighty Posted June 24, 2012 Share Posted June 24, 2012 I'm not sure if it possible but what I want to try to do is use 2 variables in a mysql query, such as: "SELECT * FROM table WHERE '$var1' = '$var2'" ; Which doesn't work, there is no error returned and the page never loads, probably messed up syntax The variables would come from a form with two text boxes, the idea being the ability to display the selected catagory with it's data. I'm sure this is not the best way to do something like this, but this is as far as I've gotten, is something like this possible? Thanks Link to comment https://forums.phpfreaks.com/topic/264707-multiple-variables-in-a-mysql-query/ Share on other sites More sharing options...
Pikachu2000 Posted June 24, 2012 Share Posted June 24, 2012 Database/table/field names don't get enclosed in quotes, only string type values do. Link to comment https://forums.phpfreaks.com/topic/264707-multiple-variables-in-a-mysql-query/#findComment-1356690 Share on other sites More sharing options...
codeeighty Posted June 25, 2012 Author Share Posted June 25, 2012 I should have included the whole string $myQuery1 = "SELECT * FROM table WHERE '$var1' = '$var2'" ; Link to comment https://forums.phpfreaks.com/topic/264707-multiple-variables-in-a-mysql-query/#findComment-1356714 Share on other sites More sharing options...
Mahngiel Posted June 25, 2012 Share Posted June 25, 2012 I should have included the whole string $myQuery1 = "SELECT * FROM table WHERE $var1 = $var2" ; FIFY Link to comment https://forums.phpfreaks.com/topic/264707-multiple-variables-in-a-mysql-query/#findComment-1356718 Share on other sites More sharing options...
codeeighty Posted June 25, 2012 Author Share Posted June 25, 2012 Thanks, that works if one field has only numbers for data, but I still need to check it out some more. Link to comment https://forums.phpfreaks.com/topic/264707-multiple-variables-in-a-mysql-query/#findComment-1356784 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.