son Posted May 8, 2009 Share Posted May 8, 2009 I would like to run a query with data from a session holding the relevant country. Running my query hard-coding a country works fine, but trying to store the session data in variable and use this one does not. The static working code is: echo $_SESSION['country']; $q = "SELECT country_id FROM countriesInt WHERE country = 'Austria' "; $r = mysqli_query ($dbc, $q); $row = mysqli_fetch_assoc ($r); $country_id = $row['country_id']; echo $country_id; I tried: $ac = echo $_SESSION['country']; $q = "SELECT country_id FROM countriesInt WHERE country = '$ac' "; $r = mysqli_query ($dbc, $q); $row = mysqli_fetch_assoc ($r); $country_id = $row['country_id']; echo $country_id; but cannot get it work. Where am I going wrong?Son Link to comment Share on other sites More sharing options...
roondog Posted May 8, 2009 Share Posted May 8, 2009 I assume you have set $_SESSION['country']try $ac = $_SESSION['country'] rather than $ac = echo $_SESSION['country'] Link to comment Share on other sites More sharing options...
son Posted June 7, 2009 Author Share Posted June 7, 2009 I assume you have set $_SESSION['country']try $ac = $_SESSION['country'] rather than $ac = echo $_SESSION['country']Thanks that did the trick. Sorry for late reply. I thought whole time I did get back to you already...Son Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.