$varibale in WHERE clause

This code has stopped working - not sure when, the php is 5.2.12, mysql 5.0.89.

It is called by file.php?lang=2 where 2 is the row id.

The problem is that it is not returning results and I think the problem is with this line

$sql = "SELECT * from `contact` WHERE langid = '".$lang."'";

I’ve tried lots of variations for the syntax around $lang, but can’t get it to work. I also added this line as I was originally getting ‘undefined variable’

$lang = $_POST["lang"];

here is the full code… any ideas?

$lang = $_POST["lang"];

$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$conn)
		die('Could not connect: ' . mysql_error());
$db_selected = mysql_select_db("$dbname",$conn);

$sql = "SELECT * from `contact` WHERE langid = '".$lang."'";
$demoResult = mysql_query($sql,$conn);
$demoRow = mysql_fetch_row($demoResult);

//$result = mysql_query($demoRow) or die ("Error: " . mysql_error() );


The query string (everything after the question mark in a URL) is accessed through $_GET

Doh! - of course :slight_smile:

Thanks Dan