External form and $.ajax

Im trying to populate a chained select with ajax but im getting a error as you can see in the attachment. im working with external forms and i have the following code:

Teste - external form
<?php   defined('C5_EXECUTE') or die(_("Access Denied.")); 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript" src="<?php  echo $this->getThemePath()?>/jquery.min.js"></script>
<!--http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js... -->
<script type="text/javascript">
    var pc_id = $(this).val();

and the db.php file wich the function in external form uses.
if(isset($_POST['pc_id']) && $_POST['pc_id'] != '')
  $pc_id = $_POST['pc_id'];
  $pc_id = mysql_real_escape_string($pc_id);
  $query = "SELECT condisciplinas.Cod_disciplinas, condisciplinas.Nome_disciplinas, concursos.Cod_curso
FROM condisciplinas INNER JOIN (concursos INNER JOIN concursodisciplina ON concursos.Cod_curso = concursodisciplina.Curso) ON condisciplinas.Cod_disciplinas = concursodisciplina.Disciplina WHERE (((concursos.Cod_curso)='".$pc_id."'))";
  $res = mysql_query($query);
    while($row = mysql_fetch_array($res))
     echo "<option value='".$row['Cod_disciplinas']."'>".ucfirst($row['Nome_disciplinas'])."</option>";

can anyone help me on this? i really need to make it work for a project.

1 Attachment

View Replies:
andrewjaff replied on at Permalink Reply
Hi ranonymus,

It seems your sql query is not returning valid sql resource. First check your sql query and connection. Accoding to your code you have not set your sql connection.

ranonymus replied on at Permalink Reply
its working!! thanks a lot!
can u just tell me how i make the select allow special characters? portuguese ones