[Linux-programlama] Connection Class

---------

[Linux-programlama] Connection Class

From: Erdal YAZICIOGLU <erdal.yazicioglu_at_gmail.com>
Date: Sat, 14 Mar 2009 12:56:14 +0200
Message-ID: <006101c9a493$80510170$1e01a8c0@chveneburi>

Herkese merhabalar,

Gözümden kaçan birþey var mý bilemiyorum ama sabahtan beri basit bir MySQL
sorgusunu çalýþtýramadým.. Devamlý aþaðýdaki hatayý veriyor..
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource
in C:\Program Files\Apache Software
Foundation\Apache2.2\htdocs\erdal.test\ch1\classes\class.Widget.php on line
19
There was a problem: An error occured selecting from database

Class aþaðýda... Eðer yardýmcý olursanýz çok makbule geçer..Teþekkürler

<?php
class Ports{

  private $id;
  private $name;
  private $description;
  private $connection;
  private $update = false;

  public function __construct($switchID) {
   $this->connection = mysql_connect('localhost','root','xxx','xxx');
   if(!is_resource($this->connection)){
   throw new Exception('Unable to connect database server');
   }
   $sql = "SELECT \"name\", \"description\" FROM switches WHERE switchid =
                $switchID";
   $result = mysql_query($this->connection, $sql);

   if(!is_resource($result)){
   throw new Exception('An error occured selecting from database');
   }
   if(!mysql_num_row($result)){
   throw new Exception('The specified switch does not exist');
   }
   $data = mysql_fetch_array($result);
   $this->id = $switchID;
   $this->name = $data['name'];
   $this->description = $data['description'];
   }

  public function getName() {
  return $this->name;
  }

  public function getDescription(){
  return $this->description;
  }

  public function setName($name){
  $this->name = $name;
  $this->update=true;
  }

  public function setDescription($description){
  $this->description = $description;
  $this->update = true;
  }

Tekrar çok teþekkürler

Erdal YAZICIOGLU
Field Project Engineer Manager
Page Europa
A GENERAL DYNAMICS COMPANY
Ras Laffan Industrial City
Doha, Qatar
Mobile: +974 325 4479

_______________________________________________
Linux-programlama mailing list
Linux-programlama_at_liste.linux.org.tr
http://liste.linux.org.tr/mailman/listinfo/linux-programlama
Received on Sat 14 Mar 2009 - 11:40:56 EET

---------

Bu arsiv hypermail 2.2.0 tarafindan uretilmistir.