If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Threaded View

PHP randomly stops output when displaying MySQL Result

Hey there,

I'm relatively new to PHP and I got a problem I just cannot seem to solve. I have to display a <select>-box filled with values from a MySQL-database. Since I have to do this very often and for a lot of different tables, I wrote this function:

PHP Code:

/****************************************************************************
* Prints a <select>-Combobox
* $sql(String): An SQL-Statement, used to gather the data vor the box
* $name(String): The name vor the <select>
* $keyCol(int): The column in the result from $sql, which contains the value for the value-property of the different <option>-tags
* $valueCol(int): THe column in the result from $sql, which contains the text for the different <option>-tags
* $selected(String): A value, that should be preselected
* $includeNoVal(Boolean): if true, the printed <select> will contain a "Not specified"-option
* *************************************************************************/
function printComboBox( $sql, $name, $keyCol, $valueCol, $selected, $includeNoVal=true )
{
$db = db_connect();

The Problem is, that PHP behaves really strange when I run this code. Sometimes, it works just fine (~50% of the time). However, sometimes PHP just seems to randomly stop the output. Sometimes it even stops WITHIN one of the test-vardumps (Very special in this case: it even puts out some text that looks like the text "domain." displayed with the wrong encoding):

I have absolutely no idea what is going wrong there. As I said, WHERE it stops seems completely random. Sometimes it's in the middle of an echo, sometimes it's like above, within a call of var_dump. And sometimes it works just fine.

All the searching I did, didn't give me a solution, hope you can help me =)