PDA

View Full Version : query executes but doesn't retrieve anything


deva
04-18-2003, 07:24 PM
hi every1 I've just installed mysql on a new linux box and everything seemed 2 work fine.. then I tried to perform a normal working query through a php page... The query seems to execute correctly but doesn't retrieve any result...!?! the problem is that if I ask php to print the query on the screen, then I copy and paste it in the phpmyadmin query box and execute it there it works properly and retrieves everything just like on my old system. I thought that was a problem of user and priv so I used root user but nothing changes. I don't have any clue.

thanx in advance.

raf
04-18-2003, 07:30 PM
Welcome here.

Without the code, we don't have a clue either ;) (code from php page to build, execute and loop through the recordset)

deva
04-18-2003, 07:50 PM
sorry you are right but the code has always worked properly that's the strangest thing....

$_SESSION[qry]=$_SESSION[qry].$_SESSION[sqlwhere]." ORDER BY NOME";
print $_SESSION[qry]; //this is 4 debug purpose
$this->res = mysql_query($_SESSION[qry]);
$_SESSION[co] =mysql_num_rows($this->res);

then on another page...

if($_SESSION[co] == 0) { .......}

I tried to remove the above .... I thought was a session problem.... forget about it.
the recordset is empty nothing to show!!

and below is the query that php prints:
SELECT L.ID, L.NOME, L.INDIRIZZO, C.COMUNE as COM, L.PROVINCIA, L.TELEFONO, L.POP, L.COD, L.CC, L.CERIM, L.PRODOTTI, L.PERNOT, L.ATTIVITA, L.MUSICA, T.TIPO FROM locali L, comuni C, tipologie T WHERE L.COMUNE = C.ID AND NONATTIVO <> 'SI' AND L.TIPO = T.ID

I repeat I didn't touch the script and it works on the other linux box so I think it is something related to mysql.

raf
04-18-2003, 08:23 PM
Hmm. This looks like some weird code to me. Why all these session variables?

did you try to run that query in a more straightforward manner? like

$link = @mysql_pconnect($server, $user, $pwd)
or die("Could not connect: " . mysql_error());
@mysql_select_db($db,$link)
or die ("Could not select database." . mysql_error());
$sql_select = "select * from table ";
$result = mysql_query($sql_select, $link);
if ($result){
echo mysql_num_rows($result) ;
}
else {
echo ("Problem: " . mysql_error());
}

deva
04-18-2003, 08:26 PM
ok sorry again I think I've found the problem...
$_SESSION stuff doesn't work.
php is 4.0.6 I guess I have to set anything in php.ini ...