|
|
#1 (permalink) |
|
Üyelik Tarihi: 28.12.2001
Yer: istanbul
Yaş: 31
Mesaj: 742
|
mysql-> php ve class
PHP ile class kullanarak birseyler yapmaya calisiyorum, normalde windows üstündeki localhostumda (apache kurulu) çalisan kodlar, internet üstünde iki ayri unix hostumda calismiyor, class içinde ki baglan ve veritabani sec fonksiyonlari calisiyor ve veritabanina baglaniyor, ama sorgula fonksiyonuna gönderdigim query yi kabul etmiyor ve burda hata veriyor, class.PHP yi edit plus da unix modunda kaydedip denedim, chmodlarin hepsini 777 ye çıkardım ama hep aynı hatayı alıyorum, kodlarda hata olmadığını düsünüyorum çünkü evdeki bilgisayarimda ve isyerindeki bilgisayarimda bulunan (windows-apache) local sunucularımda çatır çatır çalısıyor, bu neden olabilir?? tahminlere açığım
|
|
|
|
|
|
#2 (permalink) |
|
Üyelik Tarihi: 28.12.2001
Yer: istanbul
Yaş: 31
Mesaj: 742
|
windows un attıgi bir kaziktan kaynaklaniyomus tüm sorun, windows da kurulu MySQL den aldigim yedekle unix te tabloları olusturmaya kalktım ve hsMailUsers seklinde olmasi gereken tablolar windows ta hsmailusers seklinde oldugu için windowsun harflerde küçük büyük ayrımı yapmaması yüzünden, unix in küçük büyük harf ayrımının kurbanı olmusuz
|
|
|
|
|
|
#3 (permalink) |
|
Üyelik Tarihi: 27.06.2001
Yer: istanbul
Yaş: 30
Mesaj: 112
|
ayrıntıyı yakalaman çok harika olmuş tebrikler.
__________________
Bir Fikrin Ufkundayım peki Hayatımın Neresindeyim ! Fatih Murat uruninceleme.com http://www.eyioglu.com |
|
|
|
|
|
#4 (permalink) |
|
Üyelik Tarihi: 07.03.2002
Yer: Essen
Yaş: 33
Mesaj: 422
|
Hizir Bu Benim icin olan mi ? Bekleye Bekleye Agac Oldum Kök Saldim :P Bende Bos Durmayim bari.
Pekala Ben Bu Class Datei a Nasil PHP yapcam yada nasil include ile göstercem ? 2 gündür sadece bu örnekle deli oluyorum digerleri ile 2 haftadir. basket.class Bu Dosya !!!! Kod:
<?
class basket {
var $id;
var $name;
var $amount;
var $price;
var $entry;
function basket (){
// there is no base stuff needed
}
function fill_from_session($id,$name,$amount,$price){
$this->id=$id;
$this->name=$name;
$this->amount=$amount;
$this->price=$price;
}
function add_item ($id,$name,$price){
$basketcounter=0;
$updateitem=0;
$updateflag=0;
if (count($this->id)){
// only run the array if an array exists
foreach ($this->id as $basketid){
if ($id==$basketid){
// setting position to update amount of position
$updateflag=1;
$updateitem=$basketcounter;
}
$basketcounter++;
}
if ($updateflag){
// update existing item in basket
echo "updateing values<BR>";
$this->amount[$updateitem]++;
if ($this->amount[$updateitem]>1){
$this->price[$updateitem]=($this->price[$updateitem]/($this->amount[$updateitem]-1))*$this->
amount[$updateitem];
}
}else{
// add new item to existing basket
echo "Add to existing basket<BR>";
$this->id[]=$id;
$this->name[]=$name;
$this->price[]=$price;
$this->amount[]=1;
}
}else{
// att first item to basket
echo "start new basket<BR>";
$this->id[]=$id;
$this->name[]=$name;
$this->price[]=$price;
$this->amount[]=1;
}
}
function show_cart(){
$basketcounter=0;
if (count($this->id)){
foreach ($this->id as $basketid){
$itemid=$basketcounter+1;
echo '<A HREF="index.PHP?deleteitem='.$itemid.'&PHPUGSESSID=6d4ac535752a75ad1231787ac65a1249">';
echo $this->name[$basketcounter].' - ';
echo '</A>';
echo $this->price[$basketcounter].' - ';
echo $this->amount[$basketcounter].' - ';
echo '<BR>';
$basketcounter++;
}
}else{
echo "No items";
}
}
function delete_item ($itemid){
$itemid--;
$count=count($this->id);
for ($i=$itemid;$i<$count;$i++){
$basketcounter=$i+1;
$this->id[$i]=$this->id[$basketcounter];
$this->name[$i]=$this->name[$basketcounter];
$this->amount[$i]=$this->amount[$basketcounter];
$this->price[$i]=$this->price[$basketcounter];
}
array_pop ($this->id);
array_pop ($this->name);
array_pop ($this->amount);
array_pop ($this->price);
}
function delete_cart (){
unset ($this->id);
unset ($this->name);
unset ($this->price);
unset ($this->amount);
}
}
?>
Buna Calismasi icin bir PHP yapmam lazim icindeki fonksionlarda calissin diye onun icin yapimcisi aciklama vermis gelde anla ne anliyorsan. Aciklama ? SEpet Kontrol icin Object generieren: include ("basket.class"); $basket=new basket; Vairablen den session Sepete Ekel $basket->fill_from_session($bId,$bName,$bAmount,$bPrice) Sepeti Göster $basket->show_cart(); Yeni Ürün Ekle $basket->add_item ($artikelid,$artikelname,$artikelpreis); Ürün Sil $basket->delete_item($arrayposition); Sepete Bosalt $basket->delete_cart(); Aciklama Olarakda bunlar Yaziyor simdi class olani anladik vede yaptik ama birde buna PHP lazim demi bu alttaki aciklamalar ile PHP dosyasini yapiyorum nedense bir türlü eklemiyor sepete neden acaba nasil yapmam lazim örnek olarak veiriseniz sevincem. |
|
|
|
|
|
#5 (permalink) |
|
Üyelik Tarihi: 07.03.2002
Yer: Essen
Yaş: 33
Mesaj: 422
|
Bu da Benim Toparlama olan PHP dosyam Simdi burda Add to cart a bastigim zaman bunlari No items yazan yere eklemesi lazim. ama olmuyor yanilmiyorsam link vermede hata var Birde Su Bölüm :
fill_from_session($basketid,$basketname,$basketamo unt,$basketprice); Class Dosyasinda Degisik bundan yapabilirmi ? veya nasil düzeltcem Kod:
<?
// start the session
// create basket object
$basket=new basket();
/* fill basket with session variables because object canot just be stored in session*/
if (session_is_registered("basket")){
$basket->fill_from_session($basketid,$basketname,$basketamount,$basketprice);
}
/* set tax (mwst beeing the swiss name for it*/
$basket->mwst=$settings->mwst;
/* catch cart actions */
if ($deletecart)
$basket->delete_cart();
if ($deleteitem)
$basket->delete_item($deleteitem);
if ($addtocart)
$basket->add_item($bid,$bname,$bprice);
/* show the cart*/
$basket->show_cart();
/* storing variables in session to fill in on next page */
$basketid=$basket->id;
$basketname=$basket->name;
$basketamount=$basket->amount;
$basketprice=$basket->price;
session_register("basket");
session_register("basketid");
session_register("basketname");
session_register("basketamount");
session_register("basketprice");
?>
<table>
<tr>
<td><h2>catelogue</h2></td>
</tr>
<tr>
<td>expresso cups (6)</td>
<td>
<a href="index.PHP?=1&iid=001&iname=expresso&iprice=10">Add to cart</A>
</td>
</tr>
<tr>
<td>coffee machine</td>
<td>
<a href="index.PHP?addtocart=2&iid=002&iname=machine&iprice=100">Add to cart</A>
</td>
</tr>
<tr>
<td>coffee beans (java)</td>
<td>
<a href="index.PHP?addtocart=2&iid=003&iname=coffee&iprice=5">Add to cart</A>
</td>
</tr>
</table>
<hr>
<h2>shopping basket</h2>
<?
$basket->show_cart();
//session_destroy();
?>
<?
/*
session["items"][n][0] = id
session["items"][n][1] = name
session["items"][n][2] = price
session["items"][n][3] = amount
*/
class basket {
// constructor
function basket () {
// set starting count
if (!isset($_SESSION["item_count"]))
$_SESSION["item_count"] = 0;
}
function add_item ($id,$name,$price) {
if ($_SESSION["item_count"] > 0) {
$found=false;
for($i=0; $i<$_SESSION["item_count"]; $i++) {
if ($_SESSION["items"][$i][0] == $id) {
$_SESSION["items"][$i][3]++;
$found=true;
}
}
if (!$found) {
// add new item to existing basket
$_SESSION["items"][$_SESSION["item_count"]] = array($id,$name,$price,1);
$_SESSION["item_count"]++;
}
} else {
// add first item to basket
$_SESSION["items"][0] = array($id,$name,$price,1);
$_SESSION["item_count"]=1;
}
}
function show_cart() {
if (isset($_SESSION["item_count"]) && $_SESSION["item_count"] > 0) {
echo "<table border=\"1\">";
echo "<tr><td>Item(click to remove)</td><td>price</td><td>amount</td><td>subtotal</td></td></tr>";
$total = 0;
for($i=0; $i<$_SESSION["item_count"]; $i++) {
echo "<td><a href=\"cart2.PHP?deleteitem=1&iid=".$_SESSION["items"][$i][0]."\">";
echo $_SESSION["items"][$i][1]."</a></td>";
echo "<td>".$_SESSION["items"][$i][2]."</td>";
echo "<td>".$_SESSION["items"][$i][3]."</td>";
$subtotal = $_SESSION["items"][$i][2] * $_SESSION["items"][$i][3];
echo "<td align=\"right\">$subtotal</td>";
echo "</tr>";
$total += $subtotal;
}
echo "<tr><td><b>total</b></td><td align=\"right\" colspan=\"3\">$total</td></tr></table>";
}
else {
echo "No items";
}
}
function delete_item($id) {
$pos=0;
for($i=0; $i<$_SESSION["item_count"]; $i++) {
if ($_SESSION["items"][$i][0] != $id) {
$_SESSION["items"][$pos] = $_SESSION["items"][$i];
$pos++;
}
}
$_SESSION["item_count"]--;
}
function delete_cart () {
session_destroy();
}
}
?>
|
|
|
|
|
|
#7 (permalink) |
|
ne oldu xcoder yaw kusura bakmayın uzun zamandır yoğunum bir proje ile ilgileniyordum biraz buradaki sitemini gördüm bir bakayım dedim
![]() PHP Code:
![]() PHP Code:
Ufak bir tavsiye daha PHP yazarken PEAR (pear.php.net)standarlarını kullanırsan daha okunaklı olur
__________________
St. Nonstop Elektronik ve Haberleşme Mühendisi Aziz DURMAZ |
|
|
|
|
|
|
#9 (permalink) |
|
class.PHP PHP Code:
|