קבלת ערך עם תווים נוספים (תווים ריקים)

danh272

New member
קבלת ערך עם תווים נוספים (תווים ריקים)

שלום, כאשר אני שולף מהDATABASE את הנתון הבא אני מקבל אותו אבל עם תוספת של תווים ריקים,

הנה הקוד:


function doQuery($query)
{
$parameters = func_get_args();
array_shift($parameters);

$this->queryResult = $this->_doQuery($query, $parameters);
if ($this->queryResult == -1)
$this->getError();
else
parent::Success();


return $this->queryResult;
}

function _doQuery($query, $parameters)
{
if (!parent::isConnected())
{
if (!$this->doConnect())
return -1;
}

if ($this->result)
@odbc_free_result($this->result);

parent::Query();
if (sizeof($parameters) > 0)
{
$this->result = @odbc_prepare($this->conn, $query);
if (!$this->result)
return -1;

$result = @odbc_execute($this->result, $parameters);
if (!$result)
return -1;
}
else
{
$this->result = @odbc_exec($this->conn, $query);
if (!$this->result)
return -1;
}
return @odbc_num_rows($this->result);
}


function doRead($fetch = DB_FETCH_ARRAY)
{
if ($fetch == DB_FETCH_ROW)
{
return @odbc_fetch_row($this->result);
}
else
{
return @odbc_fetch_array($this->result);
}
}

$db->doQuery('SELECT strAccountID, strCharID, strClientIP, nServerNo FROM CURRENTUSER WHERE strAccountID = ? AND strClientIP = ?', $_POST[CPD_ID], $this->getRemoteIP());

$row = $db->doRead();
if (strcmp($_POST[CPD_ID], $row['strAccountID']) !== 0)



הערך שאני מקבל של ה
$row['strAccountID'])
הוא את הערך שיש במסד הנתונים + רווחים - כאילו ככה: " DATABASE "
והדבר יוצא לכך שהמשוואה אינה נכונה כי הערכים אינם תואמים,

מדוע הדבר קורה,

תודה,
דן.
 

CaTz

New member
אולי הערכים שהכנסת היו עם רווחים?

אם זה המצב, אתה יכול לתקן את כל הערכים עם שאילתת עדכון כזו:
update TableName set ColumnName = trim(ColumnName)
זה ינקה את הרווחים לפני ואחרי של כל העמודות
 

danh272

New member
נכון אבל

נכון אבל השאלה מדוע זה מתנהג ככה, כי הפונקציה הזאת מתרחשת הרבה פעמים ולפעמים זה מושך עם רווח לפעמים ללא רווח,

הבנתי שזה תלוי הרבה בהגדרות של הPHP ופילטרים מסויימים השאלה האם זאת אמת או שמשהו בקוד שלא מוגדר נכון?
 
למעלה