Page 1 of 1

invalid link resource

Posted: Tue Aug 09, 2005 11:12 am
by nawhaley
Hello I'm trying to pull some results from my database based off an input from a radio button. Then determine if it is the correct answer or not and I keep getting an errors.

Here is the relivant code

Code: Select all

$studentanswer= $_POST["answer"];
$qans = "Select * from tblAnswers where Answer='$studentanswer'";
            $qansresult = odbc_exec($link,$qans);
            $qanscorrect = odbc_result($qansresult,"Correct");
here is the error

Code: Select all

odbc_exec(): supplied argument is not a valid ODBC-Link resource in C:\\Web\\writequestion.php on line 88, referer: http://localhost/databasesessions.php
 odbc_result(): supplied argument is not a valid ODBC result resource in C:\\Web\\writequestion.php on line 89, referer: http://localhost/databasesessions.php
anyone have any ideas as to what would make this SQL statement invalid? I used one almost identical to it further up in my code like so.

Code: Select all

$queryanswers = "Select * from tblAnswers where QuestionCode ='$questioncode'";
and it works perfect does exactly what its suppose to do which is what makes this soooo confusing.

Posted: Tue Aug 09, 2005 11:16 am
by s.dot

Code: Select all

echo $studentanswer;
Looks to me like the variable you're putting in your query is not what you're expecting it to be, or is null.

Posted: Tue Aug 09, 2005 11:28 am
by nawhaley
its returning the right value I did a similar test but I had it come up in an external HTML page like so

Code: Select all

print('<A HREF = "testpost.php" TARGET = _BLANK> <EM> click here </EM> </A>');
     print("<BR>");
      $studentanswer= $_POST["answer"];
      $_SESSION["sanswer"] = $studentanswer;
thats the link to the external page along with variables.

Code: Select all

<?
session_start();
include 'writequestion.php';

print $_SESSION["sanswer"]."<BR>";
print $_SESSION["totalcorrect"]."<BR>";

?>
the actual test page

and finally results

Code: Select all

Blue
0
Blue "is" actualy the answer I selected for the first question so its pulling the variable correctly its just not translating into SQL properly.