PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
function query($sql) {
$this->result = mysql_query($sql)
or die(mysql_error());
}
should you be returning a value from this function? such as return $result
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
I haven't been able to ascertain why you are not receiving _any_ rows, but your fetch method will need a static variable to define which row to return, else it will return the same (first) row everytime it is called in the fetch_query while loop.
Either include a static variable for the row counter, e.g.:
Jenk:
The function you gave gives an endless loop (I don't know what mysql_data_seek() exactly does, I'll study that now). Anyways, the function I suggested gives diffirent results every time I call it from outside the class in a loop so I don't think that's the problem.
I think that php have a problem in assigning the row data to the $return[] var.
With error_reporting(E_ALL) set I don't get any errors. And I don't get ANY output. Whole page goes blank.
<?php
function fetch() {
static $i = 0;
if (!mysql_data_seek($this->result, $i)) {
unset($i);
return false;
} else {
$row = mysql_fetch_assoc($this->result)
or die(mysql_error());
$i++;
return $row;
}
}
?>
AHA!
I've just clicked.. your loop is also an infinite loop, following from what I mentioned earlier about the always returning the first row, that is why! The loop never breaks!