0

the following database call

$einzel = $wpdb->get_row("SELECT t.id, DATE_FORMAT(t.datum, '%d.%m.%Y'), DATE_FORMAT(t.datum2, '%d.%m.%Y'), t.ueberschrift, t.uhrzeit, t.termintext, t.veranstaltungsort, t.ort, v.name, v.id, ku.name, ku.mail
                                FROM veranstaltungen t, kalender_user ku, vereine v
                                WHERE t.id = '".$id."'
                                AND t.referfasser = ku.id
                                AND ku.verein_id = v.id", ARRAY_N );

delivers in PHPMyAdmin Database Request

In my php-scrpit

echo $einzel[0]."<br />";
echo $einzel[1]."<br />";
echo $einzel[2]."<br />";
echo $einzel[3]."<br />";
echo $einzel[4]."<br />";
echo $einzel[5]."<br />";
echo $einzel[6]."<br />";
echo $einzel[7]."<br />";
echo $einzel[8]."<br />";
echo $einzel[9]."<br />";
echo $einzel[10]."<br />";
echo $einzel[11]."<br />";

delivers these

144
21.05.2020
00.00.0000
Zugtag der Königsgilde Voitze
ab 10.00 Uhr 

Schützenhaus Voitze, Salzwedeler Straße
Voitze
Gaede,Joerg
[email protected]

Notice: Undefined offset: 10 in ...veranstaltungen.php on line 192
Notice: Undefined offset: 11 in ...veranstaltungen.php on line 193

Why don't i have access to numbers 10 and 11 here? Greeting Bernd

1
  • Can you try to print the $einzel variable and paste the output here? Aug 22, 2020 at 19:05

1 Answer 1

0

var_dump($einzel);

array(10) { [0]=> string(3) "144" [1]=> string(10) "21.05.2020" [2]=> string(10) "00.00.0000" [3]=> string(30) "Zugtag der Königsgilde Voitze" [4]=> string(14) " ab 10.00 Uhr " [5]=> string(0) "" [6]=> string(41) "Schützenhaus Voitze, Salzwedeler Straße" [7]=> string(6) "Voitze" [8]=> string(11) "Gaede,Joerg" [9]=> string(23) "[email protected]" }

There are two same column names: 'id' and 'name'. I worked around the problem and changed one column name from 'name' into 'verein' and take away one 'id' (only need one). So it works for me, but the question remains, why does it work with PHPMyAdmin, or not with wpdb.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.