what's wrong with my coding?please help.

<?php
		$a= $_POST['ques'];
		$sql="SELECT * FROM $question WHERE question=$a";
		$query=mysql_fetch_array($sql);
		while($result=mysql_fetch_array($query)){
		
		$result['id'];
		}
?>

or this one

<?php
		$sql="SELECT * FROM $question WHERE question='".$_POST['ques']."'";
		$query=mysql_fetch_array($sql);
		while($result=mysql_fetch_array($query)){
		
		$result['id'];
		}
?>

Recommended Answers

In both you need to use mysql_query:

$query=mysql_query($sql);
Jump to Post

All 4 Replies

In both you need to use mysql_query:

$query=mysql_query($sql);
commented: that's exactly it +5

As cereal says, you need to actually run the query using mysql_query as follows:

$sql=mysql_query("SELECT * FROM $question WHERE question=$a");
		$query=mysql_fetch_array($sql);
Member Avatar

how about using an echo?

$result['id'];

to

echo $result['id'];
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.