הרשם שאלות ותשובות רשימת חברים לוח שנה חיפוש הודעות מהיום סמן פורומים כנקראו

   
|!|

השב
 
כלים לאשכול תצורת הצגה
ישן 04-03-07, 15:30   # 1
ShoQER
מתאורר / יצא בחוץ
 
מיני פרופיל
תאריך הצטרפות: Dec 2006
מיקום: בית נרגילה P:
גיל: 36
הודעות: 413
שלח הודעה באמצעות ICO אל ShoQER שלח הודעה באמצעות MSN אל ShoQER Send a message via Skype™ to ShoQER

ShoQER לא מחובר  

[PHP] בעיה מוזרה בפונקציה לשליפת נתונים מהמסד

היי.

יש לי פונקציה ששולפת נתונים מהמסד.
היא מאוד פשוטה וזה...

PHP קוד:
function select($tbl = FALSE,$where = FALSE,$order = FALSE,$limit = FALSE) {
 if(
$where) {
  
$where_do = " WHERE $where";
 } else {
  
$where_do = "";
 }
 if(
$limit) {
  
$limit_do = " LIMIT $limit";
 } else {
  
$limit_do = "";
 }
 if(
$order) {
  if(
$order != "rand()") {
   
$order = explode(",",$order);
   
$order_do = " ORDER BY $order[0] $order[1]";
  } else {
   
$order_do = " ORDER BY rand()";
  }
 } else {
  
$order_do = "";
 }
 if(!
$tbl) {
  
db::set_error("You didn't set a table name.");
 }
 
$query = db::query("SELECT * FROM `{$tbl}`{$where_do}{$order_do}{$limit_do}");
 return 
$query;
} 
עכשיו...הכל עבד מצויין עד שקראתי לה ככה:
PHP קוד:
 $where = "`srLogged`='1'";
 
$order = '`srID` DESC';
 
$select = db::select('users', $where, $order); 
מה ששונה זה החלק של הORDER...הוספתי DESC... וזה יצר לי בעיה.

השגיאה:
Notice: Undefined index: 1 in C:\Program Files\EasyPHP 2.0b1\www\dreamy\source\db.php on line 56

אני כבר שעתיים שובר תראש...מנסה להבין מה השגיאה הזאת רוצה ממני...

אני ישמח מאוד אם תעזרו לי עם זה.
  Reply With Quote
ישן 04-03-07, 15:39   # 2
בניה
משתמש - היכל התהילה
 
מיני פרופיל
תאריך הצטרפות: Oct 2005
מיקום: נחושה
הודעות: 3,434

בניה לא מחובר  

תביא את כל הדף.
  Reply With Quote
ישן 04-03-07, 15:43   # 3
ShoQER
מתאורר / יצא בחוץ
 
מיני פרופיל
תאריך הצטרפות: Dec 2006
מיקום: בית נרגילה P:
גיל: 36
הודעות: 413
שלח הודעה באמצעות ICO אל ShoQER שלח הודעה באמצעות MSN אל ShoQER Send a message via Skype™ to ShoQER

ShoQER לא מחובר  

זה הDB :
PHP קוד:
<?php
class db {
function 
connect($host,$user,$pass,$db_name) {
 @
mysql_connect($host,$user,$pass) or db::set_error("Could Not Connect to the MySQL Database!");
 @
mysql_select_db($db_name) or db::set_error("Could Not Select the MySQL Database!");
}
function 
query_error($sql_query) {
 die(
'<div style="width: 500px; font-family: arial;">
 <span style="font-size: 24px"><span style="color: red">Fatal Error:</span>There is a problem with the query !</span>
 <hr style="color: red; height: 1px;">
 <span style="font-size: 15px">The Query Was:</span>
 <textarea style="width: 100%; height: 100px">'
.$sql_query.'</textarea>
 <hr style="color: red; height: 1px">
 <span style="font-size: 15px">MySQL Says:</span>
 '
.mysql_error().'
 </div>'
);
}
function 
set_error($error) {
 die(
'<div style="width: 500px; font-family: arial;">
 <span style="font-size: 24px; color: red">Fatal Error!</span>
 <hr style="color: red; height: 1px;">
 '
.$error.'
 </div>'
);
}
function 
query($sql_query) {
 
$query = mysql_query($sql_query) or db::query_error($sql_query);
 return 
$query;
}
function 
fetch($query) {
 
$return = mysql_fetch_array($query);
 return 
$return;
}
function 
select($tbl = FALSE,$where = FALSE,$order = FALSE,$limit = FALSE) {
 if(
$where) {
  
$where_do = " WHERE $where";
 } else {
  
$where_do = "";
 }
 if(
$limit) {
  
$limit_do = " LIMIT $limit";
 } else {
  
$limit_do = "";
 }
 if(
$order) {
  if(
$order != "rand()") {
   
$order = explode(",",$order);
   
$order_do = " ORDER BY $order[0] $order[1]";
  } else {
   
$order_do = " ORDER BY rand()";
  }
 } else {
  
$order_do = "";
 }
 if(!
$tbl) {
  
db::set_error("You didn't set a table name.");
 }
 
$query = db::query("SELECT * FROM `{$tbl}`{$where_do}{$order_do}{$limit_do}");
 return 
$query;
}
function 
delete($tbl = FALSE,$where = FALSE) {
 if(!
$tbl) {
  
db::set_error("You didn't set a table name to delete from.");
 }
 if(!
$where) {
  
db::set_error('You didn\'t set the "WHERE" method.');
 }
 
db::query("DELETE FROM $tbl WHERE $where");
}
function 
insert($tbl = FALSE,$values = FALSE){
 if(!
$tbl) {
  
db::set_error("You didn't set a table name to insert to.");
 }
 if(!
$values) {
  
db::set_error("You didn't set which values to insert.");
 }
 
db::query("INSERT INTO $tbl VALUES($values)");
}
function 
update($tbl = FALSE,$values = FALSE,$where = FALSE) {
 if(!
$tbl) {
  
db::set_error("You didn't set the table name to update.");
 }
 if(!
$values) {
  
db::set_error("You didn't set which values to update.");
 }
 
$values = explode(",",$values);
 
$i = 0;
 foreach(
$values as $key) {
  
$i++;
  if(
$i == 1) {
   
$comma = "";
  } else {
   
$comma = ",";
  }
  
$key = explode("#",$key);
  for(
$i=1;$i < count($key);$i++) {
   if(
$i == count($key) - 1) {
    
$telephone = "";
   } else {
    
$telephone = "#";
   }
   
$all_key .= "$key[$i]{$telephone}";
  }
  
$values_do .= "{$comma} $key[0] = '$all_key'";
 }
 if(
$where) {
  
$where_do = " WHERE {$where}";
 }
 
db::query("UPDATE $tbl SET $values_do{$where_do}");
}
function 
secure($text) {
 
$text = mysql_real_escape_string($text);
 return 
$text;
}
function 
count($text) {
 
$text = mysql_num_rows($text);
 return 
$text;
}
}
$db = new db;
?>
וזו הפונקציה המלאה שקוראת לשליפה:
PHP קוד:
function badmins() {
 
$where = "`srLogged`='1'";
 
$order = '`srID` DESC';
 
$select = db::select('users', $where, $order);
 
$lis = null;
 while(
$row = db::fetch($select)) {
  
$name = $row['srFName'];
  
$location = null;
  
$id = $row['srID'];
  
$lis .= '<li><span class="span1">'.$name.'</span><span class="span2">'.$location.'</span><a href="?op=badmin&do=logout&id='.$id.'"><img src="images/X.png" alt="נתק מנהל" /></a></li>';
 }
 return 
skin::logmanage($lis);
} 
  Reply With Quote
ישן 04-03-07, 21:27   # 4
RS324
תודה על תרומתך.
 
מיני פרופיל
תאריך הצטרפות: May 2006
הודעות: 3,173

RS324 לא מחובר  

בתוך הפונקציה אתה עושה

PHP קוד:
$order = explode(",",$order); 
ספליט לפסיק

ואתה מכניס כנתון
PHP קוד:
 $order = '`srID` DESC'; 
חסר לך פסיק באמצע

ככה :

PHP קוד:
 $order = '`srID`, DESC'; 
  Reply With Quote
השב

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 

כלים לאשכול
תצורת הצגה

חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


כל הזמנים הם GMT +2. הזמן כעת הוא 01:07.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ