Jump to content

[SOLVED] Problem Using Session Variable In Query String


stevesimo

Recommended Posts

Hi, I am attempting to pull out a record where the ID of the order is equal to the value contained in a session variable called policyRef.

 

I keep getting a parse error so am not sure what I am doing wrong.  Here is the offending line of code:

 

  $certificate = mysql_query("SELECT * from orders where PolicyID=".$_SESSION['policyRef']"");

 

Any help appreciated.

 

Thanks, Steve (Blackpool)

You have too many quotes at the end of the string. You probably want:

<?php
$certificate = mysql_query("SELECT * from orders where PolicyID=".$_SESSION['policyRef']);
?>

or

<?php
$certificate = mysql_query("SELECT * from orders where PolicyID='".$_SESSION['policyRef'] . "'");
?>

 

Ken

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.