deansaddigh Posted April 6, 2010 Share Posted April 6, 2010 $id = $_GET["id"]; session_register("id"); $query = "SELECT * FROM faq WHERE faq_id = '$_SESSION["id"]"; $result = mysql_query($query, $conn) or die('Error, query failed'); My session in the where clause wont work any help would be appreciated Thanks in advance Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted April 6, 2010 Share Posted April 6, 2010 at the top of all scripts using $_SESSION data: session_start(); $_SESSION['id'] = mysql_real_escape_string(trim($_GET['id'])); (if id is a string) -OR- $_SESSION['id'] = (int) trim($_GET['id']); (if id is an integer) Regarding session_register(): "This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged." Quote Link to comment Share on other sites More sharing options...
deansaddigh Posted April 6, 2010 Author Share Posted April 6, 2010 Thanks you very much i have changed it per your instructions. How can i put it in my where clause $query = "SELECT * FROM faq WHERE faq_id = '$_SESSION["id"]"; $result = mysql_query($query, $conn) or die('Error, query failed'); while($row= mysql_fetch_array($result)) thanks again Quote Link to comment Share on other sites More sharing options...
conker87 Posted April 6, 2010 Share Posted April 6, 2010 And don't forget to encase the $_SESSION['id'] in {} $query = "SELECT * FROM faq WHERE faq_id = '{$_SESSION['id']}'"; $result = mysql_query($query, $conn) or die('Error, query failed'); I also noticed you missed a ' at the end of the query. Quote Link to comment Share on other sites More sharing options...
deansaddigh Posted April 6, 2010 Author Share Posted April 6, 2010 Thanks for your help that fixed it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.