0

Hi,

I'm trying to query a database to pull out all results from the database where the location and server responsible are selected from a form on a previous page which are then posted over.

I can manage to post the selections from the form, but when it attempts to query the database for the selected values i get the following error message:

PHP Fatal error: Call to undefined function odbc_results() in D:\web\tivicheck\getinfo.php on line 21

Can anyone tell me why it is doing this?
I'm sure that odbc_results() is defined as i have to use it in the previous page to get the list of names to select to perform the query on the next page once you've selected one.

The code for the page is as follows:

<?php
$conn=odbc_connect('backuplogs','','');

if (!$conn)

{exit("Connection Failed: " . $conn);}

$postlocation = $_POST["t1"];
$postresponsible = $_POST["t2"];



$results="SELECT * FROM BackupLog WHERE 
Location = '$postlocation' 
AND Responsible = '$postresponsible'";

$rs=odbc_exec($conn, $results);

while (odbc_fetch_row($rs))
{
$location=odbc_results($rs, "Location");
$responsible=odbc_results($rs, "Responsible");

echo $location;
echo $responsible;
}

odbc_close($conn);
?>
2
Contributors
4
Replies
7
Views
6 Years
Discussion Span
Last Post by stonest123
0

Why not put your function(s) in a seperate file, and include that file as you need it

File1.php

function stuff()
{
     // do some stuff...
}

File2.php

include('File1.php');
$location=stuff();
echo $location;

Edited by nonshatter: n/a

0

I dont think that will help with the problem, I think its to do with the query itself. also if i remove the single quotes around $postlocation or $postresponsible i get a different error message:

PHP Warning: odbc_exec(): SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'Location = Si AND Responsible = Windows / VMware Operation'., SQL state 37000 in SQLExecDirect in D:\web\tivicheck\getinfo.php on line 16 PHP Warning: odbc_fetch_row() expects parameter 1 to be resource, boolean given in D:\web\tivicheck\getinfo.php on line 18

Edited by stonest123: n/a

1

Ohhhh apologies. I see what you're doing now...

Shouldn't it be odbc_result() instead of odbc_results() ?

Also leave the single quotes around the variables in your query otherwise mysql will enter them literally

Edited by nonshatter: n/a

0

yeah i just realized this now. thanks for pointing that out. I've been sitting here for nearly an hour trying to work it out and then it just hit me haha.

Thank you

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.