Posted: Thu Apr 05, 2007 2:29 pm
No. Everah's script demonstrates that PHP is fine and that the problem lies somewhere within your code.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
bouncer wrote:it's possible that this errors are related with php config ??
Your PHP installation is fine. Your code is not.Everah wrote:If there were a problem with PHP it would have errored in the script the same as in your script.
Code: Select all
function verificaLogin($usr, $pwd) {
$query = "select * from clients where username='$usr' and password='$pwd' and activo=1 and revenda=1";
$res = $this->cDb->abreCursor($query);
return $res;
}
function verificaSessao($name) {
$query = "select * from sessao where user='$name'";
$sres= $this->cDb->abreCursor($query);
if ($sres["user"]==$name){
$query="delete from sessao where user='$name'";
$dres = $this->cDb->executaQuery($query);
$query = "select * from clients where username='$name' and activo=1 and revenda=1";
$res = $this->cDb->abreCursor($query);
return $res;
}else{
return 0;
}
}Code: Select all
$dbclient = new client();
if ($pid) {
$ver = $dbclient->verificaSessao($pid);
} else {
$ver = $dbclient->verificaLogin($usr, $newpwd);
}
if (strlen($ver[0]["name"]) == 0) { $erro = 1; } <-- line 28
...Code: Select all
<?php
function verificaLogin($usr, $pwd) {
$query = "select * from clients where username='$usr' and password='$pwd' and activo=1 and revenda=1";
$res = $this->cDb->abreCursor($query);
echo '<pre>'; var_dump($res); echo '</pre>';
return $res;
}
function verificaSessao($name) {
$query = "select * from sessao where user='$name'";
$sres= $this->cDb->abreCursor($query);
if ($sres["user"]==$name){
$query="delete from sessao where user='$name'";
$dres = $this->cDb->executaQuery($query);
$query = "select * from clients where username='$name' and activo=1 and revenda=1";
$res = $this->cDb->abreCursor($query);
echo '<pre>'; var_dump($res); echo '</pre>';
return $res;
}
return 0;
}
?>Code: Select all
string(0) ""Code: Select all
function abreCursor ($query) {
$this->result = "";
$this->query = mysql_query($query);
if ( strlen ( trim ( mysql_error() ) ) == 0 ) {
$this->varerrorid = 0;
$this->numberrows = mysql_num_rows($this->query);
if ($this->numberrows > 0) {
$this->result = array();
while($this->result[] = mysql_fetch_assoc($this->query));
array_pop($this->result);
} else {
$this->result = "";
$this->varerrorid = 1;
$this->varerrordesc = mysql_error();
}
} else {
$this->result = "";
$this->varerrorid = 1;
$this->varerrordesc = mysql_error();
}
return $this->result;
}Code: Select all
<?php
function abreCursor ($query) {
// This should be to null as a class var
$this->result = "";
// Call the query and handle errors
if (($this->query = mysql_query($query)) === false) {
$this->varerrorid = 1;
$this->varerrordesc = mysql_error();
} 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;
}
array_pop($this->result);
}
return $this->result;
}
?>Code: Select all
string(0) ""Code: Select all
function verificaLogin($usr, $pwd) {
$query = "select * from clients where username='$usr' and password='$pwd' and activo=1 and revenda=1";
$res = $this->cDb->abreCursor($query);
return $res;
}Code: Select all
function abreCursor ($query) {
// This should be to null as a class var
$this->result = "";
// Call the query and handle errors
if (($this->query = mysql_query($query)) === false) {
$this->varerrorid = 1;
$this->varerrordesc = mysql_error();
} 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;
}
array_pop($this->result);
}
return $this->result;
}Code: Select all
<?php
function verificaLogin($usr, $pwd) {
// Delete all echoes when done testing
echo '<h2>Testing...</h2>';
$query = "select * from clients where username='$usr' and password='$pwd' and activo=1 and revenda=1";
echo '<p>The query is ' . $query . '<br />';
$res = $this->cDb->abreCursor($query);
echo '<pre>'; var_dump($this->cDb); echo '</pre>';
echo '<pre>'; var_dump($res); echo '</pre>';
return $res;
}
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);
echo '<pre>'; var_dump($this->result); echo '</pre>';
}
echo '<pre>'; var_dump($this->result); echo '</pre>';
return $this->result;
}
?>Code: Select all
Testing inside of abreCursor
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 is the mysql error description
Testing inside of abreCursor
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 is the mysql error description
Testing...
The query is select * from clients where username='test' and password='~1#@4&' and activo=1 and revenda=1
Testing inside of abreCursor
string(0) ""
object(db)#7 (6) {
["descriptor"]=>
resource(8) of type (mysql link)
["db"]=>
string(11) "incom"
["result"]=>
string(0) ""
["query"]=>
resource(12) of type (mysql result)
["varerrorid"]=>
int(0)
["numberrows"]=>
int(0)
}
string(0) ""in the top of the classWhere is the cDb object instantied inside the class?
Code: Select all
class clients {
var $cDb;
var $cConfig;
var $retorno;
function clients () {
$cConfig = new config();
$this->cDb = new db();
$this->con=$this->cDb->abreConexao($cConfig->db, $cConfig->login, $cConfig->senha,$cConfig->odbc,$cConfig->driver,$cConfig->servidor);
}