silaso
Messages postés3Date d'inscriptionsamedi 15 février 2003StatutMembreDernière intervention22 novembre 2003
-
22 nov. 2003 à 08:01
Ohm-WorK
Messages postés1464Date d'inscriptionmardi 25 octobre 2005StatutContributeurDernière intervention29 octobre 2019
-
24 mai 2006 à 19:32
Bonjour à tous,
excuser moi de nous déranger. je n'arrive dans un sript php à me connecter sur une base de donnée Mysql.
je recoit le message suivant :
Warning: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in e:\easyphp\www\portal_php4t\db_odbc.inc on line 35
Database error: Link-ID == false, odbc_pconnect failed
ODBC Error: 0 ()
j'ai besoin de l'aide s'il vous plait. le fichier db_odbc.inc est le suivant
class DB_Sql {
var $Host = "";
var $Database = "";
var $User = "";
var $Password = "";
var $UseODBCCursor = 0;
var $Link_ID = 0;
var $Query_ID = 0;
var $Record = array();
var $Row = 0;
var $Errno = 0;
var $Error = "";
var $Auto_Free = 0; ## set this to 1 to automatically free results
function connect() {
if ( 0 == $this->Link_ID ) {
$this->Link_ID=odbc_pconnect($this->Database, $this->User, $this->Password, $this->UseODBCCursor);
if (!$this->Link_ID) {
$this->halt("Link-ID == false, odbc_pconnect failed");
}
}
}
function query($Query_String) {
/* No empty queries, please, since PHP4 chokes on them. */
if ($Query_String == "")
/* The empty query string is passed on from the constructor,
* when calling the class without a query, e.g. in situations
* like these: '$db = new DB_Sql_Subclass;'
*/
return 0;
# rei@netone.com.br suggested that we use this instead of the odbc_exec().
# He is on NT, connecting to a Unix MySQL server with ODBC. -- KK
# $this->Query_ID = odbc_prepare($this->Link_ID,$Query_String);
# $this->Query_Ok = odbc_execute($this->Query_ID);
for ($i=1; $i<=$count; $i++) {
$res[$i]["table"] = $table;
$name = odbc_field_name ($id, $i);
$res[$i]["name"] = $name;
$res[$i]["type"] = odbc_field_type ($id, $name);
$res[$i]["len"] = 0; // can we determine the width of this column?
$res[$i]["flags"] = ""; // any optional flags to report?
}
odbc_free_result($id);
return $res;
}
function affected_rows() {
return odbc_num_rows($this->Query_ID);
}
function num_rows() {
# Many ODBC drivers don't support odbc_num_rows() on SELECT statements.
$num_rows = odbc_num_rows($this->Query_ID);
//printf ($num_rows."<br>");
# This is a workaround. It is intended to be ugly.
if ($num_rows < 0) {
$i=10;
while (odbc_fetch_row($this->Query_ID, $i))
$i*=10;
$j=0;
while ($i!=$j) {
$k= $j+intval(($i-$j)/2);
if (odbc_fetch_row($this->Query_ID, $k))
$j=$k;
else
$i=$k;
if (($i-$j)==1) {
if (odbc_fetch_row($this->Query_ID, $i))
$j=$i;
else
$i=$j;
};
//printf("$i $j $k <br>");
};
$num_rows=$i;
}
return $num_rows;
}
function num_fields() {
return count($this->Record)/2;
}
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);
}
bonjour !
comment se connecter avec une base doinnee ecrite en SQL server et java j'ai deja eu a appliquer multiples exemple je n'arrive pas a m'en sortir quelle driver utiliser