In my PHP I make a sql query to my database that is a list of teams. On some teams the query returns null. If I make the same query in phpmyadmin it returns the value I seeking for.
My query code:
$sql = $mysqli->query("
SELECT `team`
FROM `dota teams`
WHERE `team` LIKE '%$team%'
OR `teamalt` LIKE '%$team%'
") or die($mysqli->error);
For example if the query from my website is te it returns null, but if the query is titan it returns Titan Esports. And with Virtus Pro it return the value i want if i use vp or virtus. With NAVI i return null either what. Evil Geniuses also return value either if i write EG or Evil.
How come it can that with some name i get a returned value and with some not?
Full PHP code:
$date = $mysqli->real_escape_string(date("d\-m\-Y"));
$team = set_space($team); //Set spaces in teams so we can ute it for search
// Get team name
$sql = $mysqli->query("
SELECT `team`
FROM `dota teams`
WHERE `team` LIKE '%$team%'
OR `teamalt` LIKE '%$team%'
") or die($mysqli->error);
if($sql->num_rows>0){
$team = $sql->fetch_array();
$team = $team['team'];
// Get all the matches
$sql = $mysqli->query("
SELECT * FROM `dota schedule`
WHERE `date` >= '$date' AND `teams`
LIKE '%$team%' ORDER BY `date`,`time` ASC
") or die($mysqli->error);
// Loop through all the results
while ($data = $sql->fetch_array()){
// Change the time based on timezone
$time_arr = str_split($data['time'],3);
$hour = $time_arr[0] + $time_add;
$min = str_replace(":","",$time_arr[1]);
$time = "$hour : $min";
// Get teams
$teams = get_teams($data['teams']);
// Get casters
$caster = explode('_', $data['caster']);
foreach($caster as &$c){
$c = get_string_between($c,'[',']');
}
// Loop through to see which language the casters has.
foreach($caster as &$c){
$sqls = $mysqli->query("SELECT `language` , `stream` FROM `dota casters` WHERE `name` = '$c'") or die($mysqli->error);
$da = $sqls->fetch_array();
if($da['language'] == "English"){
$stream = $da['stream'];
$c = "<a href='$stream'><img src='http://joffe.kottnet.eu/flags/uk.png' alt='English'>$c</a>";
}
else if($da['language'] == "Russia"){
$stream = $da['stream'];
$c = "<a href='$stream'><img src='http://joffe.kottnet.eu/flags/russia.png' alt='English'>$c</a>";
}
}
?>
// Write out table.
<tr>
<td><?= "Date:" . $data['date'] . " Time: " .$time?></td>
<td><?= $data['cup'] ?></td>
<!-- 3 TD for teams -->
<td class="team1"><?= $teams[0] ?></td>
<td class="vs">VS</td>
<td><?= $teams[1] ?></td>
<td><?= print_out_array($caster); ?></td>
</tr>
<?php
}
}