ThomasaMedlem sedan aug. 2002351 inlägg Kom nu ifrån förra felet med mmcache då jag fick den "riktiga" okrypterade källkoden.
men nu får jag istället:
Fatal error: Call to undefined function mysql_connect() in lind\modules\mysql_handler.class on line 18
Försökte fixa genom att bara ta bort ; tecknet framför mysql dllen i php.ini men då blir det CGI timeout, behöver jag göra något mer?
ThomasaMedlem sedan aug. 2002351 inlägg Någon måste ju konfigurerat detta? PHP 5 / Mysql / Windows 2003 server?
väldigt tacksam för tips..
MeleaMedlem sedan juli 20033 147 inlägg Öppna php.ini och sök på "mysql" och ändra följande.
extension=php_mysql.dll
extension=php_mysqli.dll
[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent = On
; Maximum number of persistent links. -1 means no limit.
mysql.max_persistent = -1
; Maximum number of links (persistent + non-persistent). -1 means no limit.
mysql.max_links = -1
; Default port number for mysql_connect(). If unset, mysql_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
; at MYSQL_PORT.
mysql.default_port =
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =
; Default host for mysql_connect() (doesn't apply in safe mode).
mysql.default_host =
; Default user for mysql_connect() (doesn't apply in safe mode).
mysql.default_user =
; Default password for mysql_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo get_cfg_var("mysql.default_password")
; and reveal this password! And of course, any users with read access to this
; file will be able to reveal the password as well.
mysql.default_password =
; Maximum time (in secondes) for connect timeout. -1 means no limimt
mysql.connect_timeout = 60
; Trace mode. When trace_mode is active (=On), warnings for table/index scans and
; SQL-Erros will be displayed.
mysql.trace_mode = Off
[MySQLI]
; Maximum number of links. -1 means no limit.
mysqli.max_links = -1
; Default port number for mysqli_connect(). If unset, mysqli_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
; at MYSQL_PORT.
mysqli.default_port = 3306
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysqli.default_socket =
; Default host for mysql_connect() (doesn't apply in safe mode).
mysqli.default_host =
; Default user for mysql_connect() (doesn't apply in safe mode).
mysqli.default_user =
; Default password for mysqli_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo get_cfg_var("mysqli.default_password")
; and reveal this password! And of course, any users with read access to this
; file will be able to reveal the password as well.
mysqli.default_password =
; Allow or prevent reconnect
mysqli.reconnect = Off
Annars tycker jag mer det ser ut som ett kod-fel, visa hur din anslutning till MySQL ser ut.
ThomasaMedlem sedan aug. 2002351 inlägg <?PHP
class sql_handler
{
var $user;
var $password;
var $host;
var $database;
// The settings
function sql_handler($host="localhost",$database="databasen",$user="user",$password="password")
{
$this->user = $user;
$this->password = $password;
$this->host = $host;
$this->database = $database;
// The connection
$link = mysql_connect($this->host,$this->user,$this->password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db($this->database);
Såhär ser den ut, men det konstiga är att när jag gör ändringarna som du skrev i php.ini så fungerar inga php-sidor på servern, även de som inte har några databaskopplingar får timeout error.
MeleaMedlem sedan juli 20033 147 inlägg Okej, visa lite mer kod, det är är varken hela funktionen eller hela classen.
ThomasaMedlem sedan aug. 2002351 inlägg varifrån vill du ha kod, samma fil? det är hur mycket som helst =)
Du tror inte felet ligger i själva "laddningen" av php_mysql.dll eftersom den sänker alla php-sidor när jag lägger in det där i php.ini?
MeleaMedlem sedan juli 20033 147 inlägg Nej, det blir fel när du försöker anropa funktionen mysql_connect().
Visa gärna några rader till. :)
ThomasaMedlem sedan aug. 2002351 inlägg Det som följer i den filen är bara massa funktioner som skriver/läser till databasen verkar det som...
<?PHP
class sql_handler
{
var $user;
var $password;
var $host;
var $database;
// The settings
function sql_handler($host="localhost",$database="databasen",$user="user",$password="pass")
{
$this->user = $user;
$this->password = $password;
$this->host = $host;
$this->database = $database;
// The connection
$link = mysql_connect($this->host,$this->user,$this->password);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db($this->database);
}
function doQuery($query)
{
$result = mysql_query($query);
while ( $row = mysql_fetch_row($result) ) {
$theshit[] = $row;
}
return $theshit;
}
function doInsertQuery($query)
{
$result = mysql_query($query);
$id = mysql_insert_id();
return($id);
}
function doAlterQuery($query)
{
mysql_query($query);
}
function insertContentType($field)
{
$query = "insert into contenttype (description) values (\"".$field."\")";
$fid = $this->doInsertQuery($query);
$query = "insert into relation (relation) values (\"".$field."\")";
$fid = $this->doInsertQuery($query);
return($fid);
}
function insertContent($content,$contenttype)
{
$query = "insert into content (content,contenttype) VALUES (\"".$content."\",$contenttype)";
$cid = $this->doInsertQuery($query);
return($cid);
}
function alterContent($content,$contentid,$contenttype)
{
$query = "update content set content=\"".$content."\",contenttype=\"".$contenttype."\" WHERE id=$contentid";
$this->doAlterQuery($query);
return($contentid);
}
MeleaMedlem sedan juli 20033 147 inlägg Jadu, det verkar inte vara något fel på din klass, inte vad jag kan se iallafall.
Får väl vänta tills någon annan piggare person kan luska ut var felet ligger.