Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Klasa dla BD w OOP Php5
Forum PHP.pl > Forum > PHP
webJ@cob
Witam,

Cały czas dostaje komunikat o błędnym\nieznanym linku do bazy.

Skrypt wyglada tak:

<?php
/*
DB connector by Jakub Mróz (www.webArts.pl)
Class responsible for database connections
release 03.09.v1b
*/

class dbconn {
protected $link;
private $server, $username, $password, $db;

public function __contruct($server, $username, $password, $db)
{
$this->server = $server;
$this->username = $username;
$this->password = $password;
$this->db = $db;
$this->connect();
}

public function __destruct()
{
mysql_close($this->link);
}

/* Database connect function */
private function connect()
{
$this->link = mysql_connect($this->server, $this->username, $this->password);
mysql_select_db($this->db, $this->link);
}

/*
Simple SQL Fetcher
Returns: sql execution result
*/
public function execute($sql)
{
$this->connect();
return mysql_query($sql, $this->link);
}

/* Registrations of a new patient */
public function regPatient($firstname, $surname, $weight, $pesel)
{

// jacob's Simple Anty-hack tool winksmiley.jpg
$firstname=addslashes($firstname);
$secondname=addslashes($secondname);
# Must be . in float
$weight = (float)str_replace(",",".",$weight);

//if ( (($weight>=0.100) && ($weight<=500.000)) && !empty($firstname) && !empty($surname) && (strlen($pesel)==11) )
//{
return $this->execute("INSERT INTO patient(firstname, surname, weight, pesel) VALUES('$firstname','$secondname',".(float)$weight.", ".(int)$pesel.")");
//} else {
//return 'err';
//}
}

}

?>

co jest nie tak?
erix
Dodaj bbcode do treści listingu.
keyzen
Literówka tongue.gif

__contruct -> __construct
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.