Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Klasa dla BD w OOP Php5
webJ@cob
post 23.03.2009, 17:35:56
Post #1





Grupa: Zarejestrowani
Postów: 66
Pomógł: 1
Dołączył: 28.02.2007
Skąd: Kraków

Ostrzeżenie: (0%)
-----


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?


--------------------
Sprawdź kiedy marzenia stają się inspiracją.
e-Zarządzania firmą | e-Biznes | Strony.Serwisy.Portale Internetowe
www.webarts.pl
Go to the top of the page
+Quote Post
erix
post 23.03.2009, 18:06:33
Post #2





Grupa: Moderatorzy
Postów: 15 467
Pomógł: 1451
Dołączył: 25.04.2005
Skąd: Szczebrzeszyn/Rzeszów




Dodaj bbcode do treści listingu.


--------------------

ZCE :: Pisząc PW załączaj LINK DO TEMATU i TYLKO w sprawach moderacji :: jakiś błąd - a TREŚĆ BŁĘDU? :: nie ponaglaj z odpowiedzią via PW!
Go to the top of the page
+Quote Post
keyzen
post 23.03.2009, 20:53:07
Post #3





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 15.02.2008

Ostrzeżenie: (0%)
-----


Literówka tongue.gif

__contruct -> __construct
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.07.2025 - 19:12