Strange problem with query Post (MySQL)

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Pozor
Forum Commoner
Posts: 74
Joined: Tue Mar 30, 2004 11:11 pm
Location: Switzerland

Strange problem with query Post (MySQL)

Post by Pozor »

hi,

my problem is that the query result is empty with this:
this runs in a normal php script on my laptop
SELECT sessid,variable,userid,timestamp FROM test_ext___ac_session WHERE sessid = '6163544fe95a5e7b267c31c3c0bec351'

with the same query in phpmyadmin it works and give me the expected result.

the table i have:

CREATE TABLE `test_ext___ac_session` (
`ac_sessionID` int(11) NOT NULL auto_increment,
`sessid` varchar(32) NOT NULL default '',
`variable` text NOT NULL,
`userid` varchar(10) default '1',
`timestamp` timestamp(14) NOT NULL,
PRIMARY KEY (`ac_sessionID`)
) TYPE=MyISAM AUTO_INCREMENT=4 ;


someone who has an idea why?

greez Pozor
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

What's the code your using that shows an empty result?
Pozor
Forum Commoner
Posts: 74
Joined: Tue Mar 30, 2004 11:11 pm
Location: Switzerland

Post by Pozor »

hi,

Code: Select all

<?php
function read($IDToRead) //finished, but not tested yet
  { //read a session and proof if it is ok...!
    $expiretime = date("YmdHis", mktime(date("H"),date("i")-$this->sessionexpiretime,date("s"),date("m"),date("d"),date("Y")));
    
    $readquery  = " SELECT sessid,variable,userid,timestamp ";
    $readquery .= " FROM ".$this->db->tbext."ac_session ";
    $readquery .= " WHERE sessid = '".$IDToRead."' ";
    //$readquery .= " AND timestamp >= '".$expiretime."' ";
    ///$readquery .= " WHERE timestamp >= '".$expiretime."' ";
    //$readquery .= " LIMIT 0,1 ";
    echo '<font color=#00BB00>'.$readquery.'</font>'; //testzweck xxxx
    $this->db->query($readquery,$this->debugMySQL,__LINE__);
    $readobj = $this->db->fetch_object($this->debugMySQL,__LINE__);
    echo '<pre>'; //testzweck xxxx
    print_r($readobj); //testzweck xxxx
    echo isset($readobj);
    echo $readobj;
    echo '</pre>'; //testzweck xxxx
    if(!empty($readobj->timestamp))
    {
      $this->userid = $readobj->userid;
      $this->sessid = $readobj->sessid;
      $this->variables = unserialize($readobj->variable);
      $proof = 1;
    }else
    {
      $proof = 0;
    }
    return $proof;                          //1: is valid, 0 is invalid
  }

//db obj functions
function query($querystring,$debug = '0',$line = 'unknown')
  { //returns the result of a query
    if(0 == $debug)
    { //error supressed
      $this->result = @mysql_query($querystring,$this->link);
    }else
    { //error showed
      $this->result = mysql_query($querystring,$this->link);
    }
    if(($debug != 0) and (0 != mysql_errno())){echo '<br>MYSQL(Query) ERROR on <b>line '.$line.':: <font color="#FF0000">'.mysql_error().'</b></font><br>';}
  }
  
  function fetch_object($debug = '0',$line = 'unknown')
  { //fetch a row as an object
    $object = mysql_fetch_object($this->result);
    if(0 == $debug)
    { //error supressed
      $object = @mysql_fetch_object($this->result);
    }else
    { //error showed
      $object = mysql_fetch_object($this->result);
    }
    if(($debug != 0) and (0 != mysql_errno())){echo '<br>MYSQL(Fetch Object) ERROR on <b>line '.$line.':: <font color="#FF0000">'.mysql_error().'</b></font><br>';}
    return $object;
  }
?>
thats what im using, the db functions are proof, they work

i had had this problem a year ago, but then i made a ugly hack and this time i wanna do the prpoer solutîon.

greez Pozor
Pozor
Forum Commoner
Posts: 74
Joined: Tue Mar 30, 2004 11:11 pm
Location: Switzerland

Post by Pozor »

hi,

i think it is a problem with the db and not with the code.

Greez Pozor
Post Reply