php query for mysql text-Collection of common programming errors

i’m having problems while querying for mysql “text” data.

here’s my code:

$result_odg = mysqli_query($con,"SELECT * FROM agenda WHERE data = '" . $today . "' AND odg IS NOT NULL");
echo "

ODG:

";

if (mysqli_fetch_array($result_odg)) {
    $i = 1;
    echo "

“; while($row = mysqli_fetch_array($result_odg)) { if($i % 2 == 0) $cellID = “even”; else $cellID = “odd”; echo “”; $i == $i++; } echo ”

” . $row[‘testo’] . “

"; } else { echo "No ODG"; }

the table have the following fields: id, data_ins, data, testo, odg, agenda, ok.

using any other name than “testo” in $row['testo'] (example $row['id']) will print out the text. is there any special query to do for “TEXT” type fields? maybe because it’s too heavy and needs a particular array? can’t find anything about this on the manual…

  1. please use

    // no need to fetch the result for check (shorten runtime time)
    if ($result_odg) {
    
        while($row = mysqli_fetch_assoc($result_odg)) {
            // use $row['testo'] is possible
    
            // replace this too
            $i++;
        }
    }
    
  2. To make query fast select only those fields which needed.In this case your query should be like:

    $result_odg = mysqli_query($con,"SELECT testo FROM agenda WHERE data = '" . $today . "' AND odg IS NOT NULL");