I’m having some issues returning values from a server with php + mysql.
This is my code
$result = mysql_query("SELECT * FROM Nicknames", $con);
if (mysql_real_escape_string($_POST['Create']) == "NICKNAME") {
$output;
while ($row = mysql_fetch_assoc($result)) {
if ($row['Taken'] == '0') $output = $output . $row['Nickname'] . ",";
}
echo substr($output, 0, -1);
}
If I add break; in the while loop, it works perfectly and I just get 1 row of my table.
If instead I want to return all 3000 rows, I just get an empty answer from the server.
If the table has 10 rows it works.
I was wondering if it is about the amount of rows, or it is because eventual special characters.
thanks
UPDATE
It works until 1330 rows, if I try to get more, I get an empty result
$counter = 0;
while ($row = mysql_fetch_assoc($result)) {
if ($row['Taken'] == '0') $output = $output . $row['Nickname'] . ",";
if ($counter == 1330) break;
$counter++;
}
echo substr($output, 0, -1);
Somewhere in the middle of your table’s rows there may have been an invalid character.
Since you know which row it stops working at, try running the SELECT with different ORDER BY’s to determine if this is the case. 🙂