Estou a fazer uma página em PHP com ligação a uma BD SQL 2000. O que acontece é que não vejo infromação nenhuma. Penso que o problema reside na ligação. Deixo aqui os ficheiros para quem me possa ajudar. Experimentem este código nos vossos computadores e vejam se funciona. Será só necessário fazer uma pequenita BD. Pelo menos explicam-me o que está mal na ligação com a BD. Pois quanto ponho a página a correr não vejo informação nenhuma. nem sequer um simples echo.... Clientes.html --- <html> <head> <title>Code</title> <meta http-equiv="pragma" content="no-cache"> <meta http-equiv="expires" content="0"> <meta http-equiv="cache-control" content="no-cache"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"></head> <body > {Header} <table> <tr> <td valign="top"> <!--BeginFormClientesHeader--> <!--EndFormClientesHeader--> <!--BeginFormClientes--><table > <tr> <td colspan="3"><a name="Clientes"><font >{FormTitle}</font></a></td> </tr> <tr> <td ><font >Nome</font></td> <td ><font >Idade</font></td> <td ><font >Morada</font></td> </tr> <!--BeginDListClientes--> <tr> <td ><font >{Nome} </font></td> <td ><font >{Idade} </font></td> <td ><font >{Morada} </font></td> </tr> <!--EndDListClientes--> <!--BeginClientesNoRecords--> <tr><td colspan="3" ><font >Nenhuns Registos</font></td></tr> <!--EndClientesNoRecords--> </table> <!--EndFormClientes--> <!--BeginFormClientesFooter--> <!--EndFormClientesFooter--> </td> </tr> </table> {Footer} </body> </html> ---- Clientes.php ---- <?php include ("./common.php"); session_start(); $filename = "ClientesGrid.php"; $template_filename = "ClientesGrid.html"; $sAction = get_param("FormAction"); $sForm = get_param("FormName"); $tpl = new Template($app_path); $tpl->load_file($template_filename, "main"); $tpl->set_var("FileName", $filename); Clientes_show(); $tpl->pparse("main", false); function Clientes_show() { global $tpl; global $db; global $sClientesErr; $sWhere = ""; $sOrder = ""; $sSQL = ""; $sFormTitle = "Clientes"; $HasParam = false; $tpl->set_var("TransitParams", ""); $tpl->set_var("FormParams", ""); $sSQL = "select C.Id as C_Id, " . "C.Idade as C_Idade, " . "C.Morada as C_Morada, " . "C.Nome as C_Nome " . " from Clientes C "; $sSQL .= $sWhere . $sOrder; $tpl->set_var("FormTitle", $sFormTitle); $db->query($sSQL); $next_record = $db->next_record(); echo $db; if(!$next_record) { $tpl->set_var("DListClientes", ""); $tpl->parse("ClientesNoRecords", false); $tpl->parse("FormClientes", false); return; } while($next_record ) { $fldId = $db->f("C_Id"); $fldIdade = $db->f("C_Idade"); $fldMorada = $db->f("C_Morada"); $fldNome = $db->f("C_Nome"); echo $fldNome; $next_record = $db->next_record(); $tpl->set_var("Id", tohtml($fldId)); $tpl->set_var("Nome", tohtml($fldNome)); $tpl->set_var("Idade", tohtml($fldIdade)); $tpl->set_var("Morada", tohtml($fldMorada)); echo $tp1; $tpl->parse("DListClientes", true); } $tpl->set_var( "ClientesNoRecords", ""); $tpl->parse( "FormClientes", false); } ?> ------------- db_mssql.php -------- <?php class DB_Sql { var $Host = ""; var $Database = ""; var $User = ""; var $Password = ""; var $Link_ID = 0; var $Query_ID = 0; var $Record = array(); var $Row = 0; var $Errno = 0; var $Error = ""; var $Auto_Free = 0; function DB_Sql($query = "") { $this->query($query); } function connect() { if ( 0 == $this->Link_ID ) { $this->Link_ID=@mssql_pconnect($this->Host, $this->User, $this->Password); if (!$this->Link_ID) $this->halt("Link-ID == false, mssql_connect failed"); else mssql_select_db($this->Database, $this->Link_ID); } } function free_result(){ mssql_free_result($this->Query_ID); $this->Query_ID = 0; } function query($Query_String) { if ($Query_String == "") return 0; $Query_String = str_replace("\\\\", "\\", $Query_String); if (!$this->Link_ID) $this->connect(); $this->Query_ID = mssql_query($Query_String, $this->Link_ID); $this->Row = 0; if (!$this->Query_ID) { $this->Errno = 1; $this->Error = "General Error (The MSSQL interface cannot return detailed error messages)."; $this->halt("Invalid SQL: ".$Query_String); } return $this->Query_ID; } function next_record() { if ($this->Record = mssql_fetch_row($this->Query_ID)) { $count = mssql_num_fields($this->Query_ID); for ($i=0; $i<$count; $i++){ $fieldinfo = mssql_fetch_field($this->Query_ID,$i); $this->Record[strtolower($fieldinfo->name)] = $this->Record[$i]; } $this->Row += 1; $stat = 1; } else { if ($this->Auto_Free) { $this->free_result(); } $stat = 0; } return $stat; } function seek($pos) { mssql_data_seek($this->Query_ID,$pos); $this->Row = $pos; } function metadata($table) { $count = 0; $id = 0; $res = array(); $this->connect(); $id = mssql_query("select * from $table", $this->Link_ID); if (!$id) { $this->Errno = 1; $this->Error = "General Error (The MSSQL interface cannot return detailed error messages)."; $this->halt("Metadata query failed."); } $count = mssql_num_fields($id); for ($i=0; $i<$count; $i++) { $info = mssql_fetch_field($id, $i); $res[$i]["table"] = $table; $res[$i]["name"] = $info["name"]; $res[$i]["len"] = $info["max_length"]; $res[$i]["flags"] = $info["numeric"]; } $this->free_result(); return $res; } function affected_rows() { return mssql_affected_rows($this->Query_ID); } function num_rows() { return mssql_num_rows($this->Query_ID); } function num_fields() { return mssql_num_fields($this->Query_ID); } function nf() { return $this->num_rows(); } function np() { print $this->num_rows(); } function f($Field_Name) { return $this->Record[strtolower($Field_Name)]; } function p($Field_Name) { print $this->f($Field_Name); } function halt($msg) { printf("</td></tr></table><b>Database error:</b> %s<br>\n", $msg); printf("<b>MSSQL Error</b>: %s (%s)<br>\n", $this->Errno, $this->Error); die("Session halted."); } } ?> ---- comom.asp ----- <?php error_reporting (E_ALL ^ E_NOTICE); include("./template.php"); include("./db_mssql.php"); define("DATABASE_NAME","BD_exp"); define("DATABASE_USER","sa"); define("DATABASE_PASSWORD","4582875"); define("DATABASE_HOST","192.100.4.210"); $db = new DB_Sql(); $db->Database = DATABASE_NAME; $db->User = DATABASE_USER; $db->Password = DATABASE_PASSWORD; $db->Host = DATABASE_HOST; $app_path = "."; function tohtml($strValue) { return htmlspecialchars($strValue); } function tourl($strValue) { return urlencode($strValue); } function get_param($param_name) { global $HTTP_POST_VARS; global $HTTP_GET_VARS; $param_value = ""; if(isset($HTTP_POST_VARS[$param_name])) $param_value = $HTTP_POST_VARS[$param_name]; else if(isset($HTTP_GET_VARS[$param_name])) $param_value = $HTTP_GET_VARS[$param_name]; return $param_value; } function get_session($parameter_name) { global $HTTP_SESSION_VARS; return isset($HTTP_SESSION_VARS[$parameter_name]) ? $HTTP_SESSION_VARS[$parameter_name] : ""; } function set_session($parameter_name, $parameter_value) { global $HTTP_SESSION_VARS; global ${$parameter_name}; if(session_is_registered($parameter_name)) { session_unregister($parameter_name); } ${$parameter_name} = $parameter_value; session_register($parameter_name); $HTTP_SESSION_VARS[$parameter_name] = $parameter_value; } function is_number($string_value) { if(is_numeric($string_value) || !strlen($string_value)) return true; else return false; } function tosql($value, $type) { if(!strlen($value)) return "NULL"; else if($type == "Number") return str_replace (",", ".", doubleval($value)); else { if(get_magic_quotes_gpc() == 0) { $value = str_replace("'","''",$value); $value = str_replace("\\","\\\\",$value); } else { $value = str_replace("\\'","''",$value); $value = str_replace("\\\"","\"",$value); } return "'" . $value . "'"; } } function strip($value) { if(get_magic_quotes_gpc() == 0) return $value; else return stripslashes($value); } function db_fill_array($sql_query) { global $db; $db_fill = new DB_Sql(); $db_fill->Database = $db->Database; $db_fill->User = $db->User; $db_fill->Password = $db->Password; $db_fill->Host = $db->Host; $db_fill->query($sql_query); if ($db_fill->next_record()) { do { $ar_lookup[$db_fill->f(0)] = $db_fill->f(1); } while ($db_fill->next_record()); return $ar_lookup; } else return false; } function dlookup($table_name, $field_name, $where_condition) { $sql = "SELECT " . $field_name . " FROM " . $table_name . " WHERE " . $where_condition; return get_db_value($sql); } function get_db_value($sql) { global $db; $db_look = new DB_Sql(); $db_look->Database = $db->Database; $db_look->User = $db->User; $db_look->Password = $db->Password; $db_look->Host = $db->Host; $db_look->query($sql); if($db_look->next_record()) return $db_look->f(0); else return ""; } function get_checkbox_value($value, $checked_value, $unchecked_value, $type) { if(!strlen($value)) return tosql($unchecked_value, $type); else return tosql($checked_value, $type); } function get_lov_value($value, $array) { $return_result = ""; if(sizeof($array) % 2 != 0) $array_length = sizeof($array) - 1; else $array_length = sizeof($array); reset($array); for($i = 0; $i < $array_length; $i = $i + 2) { if($value == $array[$i]) $return_result = $array[$i+1]; } return $return_result; } function check_security() { $return_page = getenv("REQUEST_URI"); if($return_page === "") { $return_page = getenv("SCRIPT_NAME") . "?" . getenv("QUERY_STRING"); } if(!session_is_registered("UserID")) { header ("Location: .php?querystring=" . urlencode(getenv("QUERY_STRING")) . "&ret_page=" . urlencode($return_page)); exit; } } ?> ---- Cumpts. carla