I want to get survey questions from MySQL database, where pollid=1 and echo them out.
I have following code:
<?php
include_once 'init/init.funcs.php';
$pollid=$_GET['pollid'];
$result = mysql_query('SELECT kysimus FROM kysimused where survey_id="1"');
$question = mysql_result($result, 0);
echo $pollid;
echo $question;
?>
It works and I see first question from database, where survey_id =1. But when I write:
<?php
include_once 'init/init.funcs.php';
$pollid=$_GET['pollid'];
$result = mysql_query('SELECT kysimus FROM kysimused where survey_id="$pollid"');
$question = mysql_result($result, 0);
echo $pollid;
echo $question;
?>
It says:
Warning: mysql_result() expects parameter 1 to be resource, boolean given in C:\xampp2\htdocs\Praks\answering.php on line 5
In last example I inserted pollid from url and I am sure that variable $pollid got value '1'. Why the second code doesnt work? I have second question too, how could I create an array of all the questions, which have survey_id = $pollid.Thanks in advance.