0

I have a popup with a drop down but the echo don't work, why?

if (($aData2['rennen'] == 6)) {
    print"Es nehmen bereits 6 Fahrer an diesem Rennen teil, bitte Name des Rennnens ändern";
    exit;
}
Qirel
  • 25,449
  • 7
  • 45
  • 62
j.m.l
  • 27
  • 1

3 Answers3

0

Before your condition, add a echo $aData2['rennen']; to check if the value is 6. Then in this case use echo instead of print. Print can be used for tests.

J. Grunder
  • 143
  • 2
  • 13
  • 1
    print can (and frequently is) be used as an alternative to echo..... it is not simply for tests (in fact it isn't even particularly useful for tests `$x = false; print $x;` is no different to `$x = false; echo $x;` and both will display nothing.... but at least you're suggesting displaying the value of `$aData2['rennen']` as a basic debugging – Mark Baker Dec 09 '15 at 14:32
  • OK, I understand what you mean, I never use print and use echo. I wrote test but I meant function. I based by answer with this topic : http://stackoverflow.com/questions/234241/how-are-echo-and-print-different-in-php – J. Grunder Dec 09 '15 at 15:06
0
$sSql = "SELECT Auto FROM Fahrer WHERE Auto = '$Auto'AND Rennen='$Rennen'";
$stmt = $pdo->query($sSql);
$aData2 = $stmt->fetch(2);

if(!empty($aData2)) {
    exit;
}
$sSql = "SELECT COUNT(Rennen) AS rennen FROM Fahrer WHERE Rennen='$Rennen'";
$stmt = $pdo->query($sSql);
$aData2 = $stmt->fetch(2);

if($aData2['rennen']==6){
    echo "Es nehmen bereits 6 Fahrer an diesem Rennen teil, bitte Name des Rennnens ändern";
    exit;
}


$sql = "INSERT into Fahrer (Auto,Vorname,Rennen) VALUES('$Auto','$Name','$Rennen');";
$pdo->query($sql); 

this more code of my site

j.m.l
  • 27
  • 1
-1

Try this one:

if(($aData2['rennen']==6)) 
{ 
echo 'Es nehmen bereits'.$aData2['rennen'].'Fahrer an diesem Rennen teil, bitte Name des Rennnens ändern';
exit; 
}
Herolind
  • 43
  • 5
  • 2
    And what's the difference? Besides using `echo` instead of `print`? Why should this display output when OP's doesn't? – Mark Baker Dec 09 '15 at 14:25
  • echo and print are more or less the same. They are both used to output data to the screen. The differences are small: echo has no return value while print has a return value of 1 so it can be used in expressions. echo can take multiple parameters (although such usage is rare) while print can take one argument. – Herolind Dec 09 '15 at 14:26
  • 1
    I know what the differences are between `echo` and `print`..... what I don't see is why this code should do anything different than the OP's...... if you suggest something to try, explain ___why___ the OP should try it.... why might this work when their own code doesn't? – Mark Baker Dec 09 '15 at 14:29
  • print only takes one parameter, while echo can have multiple parameters. print returns a value (1), so can be used as a function. echo is slightly faster. Speed. There is a difference between the two, but speed-wise it should be irrelevant which one you use. echo is marginally faster since it doesn't set a return value if you really want to get down to the nitty gritty. Expression. print() behaves like a function in that you can do: $ret = print "Hello World"; And $ret will be 1. That means that print can be used as part of a more complex expression where echo cannot – Herolind Dec 09 '15 at 14:33
  • 1
    you're beginning to repeat yourself, and still not answering my question - there's no reason why using `echo` will make any difference to using `print` here – Mark Baker Dec 09 '15 at 14:35