Posted: Tue Apr 10, 2007 10:33 am
yes, but i'm not understanding this error ... there's something wrong with query ?Everah wrote:Notice the SQL error reports up there?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
yes, but i'm not understanding this error ... there's something wrong with query ?Everah wrote:Notice the SQL error reports up there?
i have rewrited my function to this one, but the $pwd appears with the same restricted charactersEverah wrote:Have you tried mysql_real_escape_string()?
Code: Select all
function verificaLogin($usr, $pwd) {
$query = sprintf("SELECT * FROM clients WHERE username='%s' AND password='%s' AND activo=1 AND revenda=1",
mysql_real_escape_string($usr),
mysql_real_escape_string($pwd));
$res = $this->cDb->abreCursor($query);
return $res;
}The current character set is: latin1Everah wrote:I wonder if your character encoding is causing this. Do you happen to know what charset you are using?
Code: Select all
function prepare_string($s) {
// + lots of error handling
$ps = mysql_real_escape_string($s, $this->mysqlconn);
return $ps;
}in abreCursor byecho '<p>' . $this->varerrordesc . ' is the mysql error description<br />';
Code: Select all
echo "<p>Debug: \n",
'query: ', htmlentities($query), "<br />\n",
'error: ', $this->varerrordesc,
"</p>\n";Code: Select all
$res = $this->cDb->abreCursor($query);
echo '<pre>'; var_dump($this->cDb); echo '</pre>';
echo '<pre>'; var_dump($res); echo '</pre>';Please (always) post the real output of your debug code. And it's usually better to have some unconditional output so that you know wether the script really reached the echo/var_dumpbouncer wrote:both, $this->cDb and $res are empty
Code: Select all
echo '<pre>this->cDb: '; var_dump($this->cDb); echo '</pre>';
echo '<pre>res: '; var_dump($res); echo '</pre>';Code: Select all
function abreCursor ($query) {
// This should be to null as a class var
$this->result = "";
echo '<h2>Testing inside of abreCursor</h2>';
// Call the query and handle errors
if (($this->query = mysql_query($query)) === false) {
$this->varerrorid = 1;
$this->varerrordesc = mysql_error();
echo '<p>' . $this->varerrordesc . ' is the mysql error description<br />';
} else {
$this->varerrorid = 0;
$this->numberrows;
if (($this->numberrows = mysql_num_rows($this->query)) > 0) {
$this->result = array();
while ($row = mysql_fetch_assoc($this->query)) {
$this->result[] = $row;
}
echo '<pre>'; var_dump($this->result); echo '</pre>';
array_pop($this->result); <- problem
echo '<pre>'; var_dump($this->result); echo '</pre>';
}
echo '<pre>'; var_dump($this->result); echo '</pre>';
return $this->result;
}
}